From 111829573d1c048d4c4c4e4d98b114eba9c28196 Mon Sep 17 00:00:00 2001 From: hukl Date: Thu, 19 Feb 2009 22:40:27 +0100 Subject: adding the admin controller and his friends --- app/controllers/admin_controller.rb | 12 ++++++++++++ app/helpers/admin_helper.rb | 11 +++++++++++ app/views/admin/index.html.erb | 5 +++++ app/views/layouts/admin.html.erb | 8 +++++++- test/functional/admin_controller_test.rb | 8 ++++++++ test/unit/helpers/admin_helper_test.rb | 4 ++++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin_controller.rb create mode 100644 app/helpers/admin_helper.rb create mode 100644 app/views/admin/index.html.erb create mode 100644 test/functional/admin_controller_test.rb create mode 100644 test/unit/helpers/admin_helper_test.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb new file mode 100644 index 0000000..e672e3b --- /dev/null +++ b/app/controllers/admin_controller.rb @@ -0,0 +1,12 @@ +class AdminController < ApplicationController + + def index + end + + def switch_locale + I18n.locale = params[:id].to_sym + + render :controller => 'nodes', :action => 'index' + end + +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 0000000..7122584 --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,11 @@ +module AdminHelper + + def language_selector + case I18n.locale + when :de + link_to 'Deutsch', edit_node_path(@node, :locale => :en) + when :en + link_to 'Deutsch', :locale => :de, :controller => params[:controller], :action => params[:action] + end + end +end \ No newline at end of file diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb new file mode 100644 index 0000000..0a9874f --- /dev/null +++ b/app/views/admin/index.html.erb @@ -0,0 +1,5 @@ +

Admin#index

+

Find me in app/views/admin/index.html.erb

+ + +<%= link_to 'nodes', :controller => :nodes, :action => :index %> \ No newline at end of file diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index df5b014..deebc66 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -24,6 +24,12 @@ - <%= yield :layout %> + +
+ <%= yield :layout %> +
diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb new file mode 100644 index 0000000..9bbf29b --- /dev/null +++ b/test/functional/admin_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class AdminControllerTest < ActionController::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end diff --git a/test/unit/helpers/admin_helper_test.rb b/test/unit/helpers/admin_helper_test.rb new file mode 100644 index 0000000..23d9f40 --- /dev/null +++ b/test/unit/helpers/admin_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class AdminHelperTest < ActionView::TestCase +end -- cgit v1.3