From 0eb5e8104b5dd4a0d143f52a8e3872ffba83bad2 Mon Sep 17 00:00:00 2001 From: nilsding Date: Wed, 10 Dec 2014 17:01:59 +0100 Subject: [PATCH] added RailsAdmin --- Gemfile | 2 ++ Gemfile.lock | 26 +++++++++++++++++ config/initializers/rails_admin.rb | 45 ++++++++++++++++++++++++++++++ config/routes.rb | 1 + 4 files changed, 74 insertions(+) create mode 100644 config/initializers/rails_admin.rb diff --git a/Gemfile b/Gemfile index 41d1f479..2e62758b 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,8 @@ gem 'rails-assets-growl' gem 'ruby-progressbar' +gem 'rails_admin' + gem 'questiongenerator' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index c5ba3e84..4637d63c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,7 +89,12 @@ GEM jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks + jquery-ui-rails (5.0.3) + railties (>= 3.2.16) json (1.8.1) + kaminari (0.16.1) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) kgio (2.9.2) mail (2.6.3) mime-types (>= 1.16, < 3) @@ -98,6 +103,7 @@ GEM minitest (5.4.3) multi_json (1.10.1) mysql2 (0.3.17) + nested_form (0.3.2) nokogiri (1.6.5) mini_portile (~> 0.6.0) nprogress-rails (0.1.6.3) @@ -110,6 +116,9 @@ GEM websocket-driver (>= 0.2.0) questiongenerator (0.0.1) rack (1.5.2) + rack-pjax (0.8.0) + nokogiri (~> 1.5) + rack (~> 1.1) rack-test (0.6.2) rack (>= 1.0) rails (4.1.8) @@ -125,6 +134,20 @@ GEM rails-assets-growl (1.2.4) rails-assets-jquery rails-assets-jquery (2.1.1) + rails_admin (0.6.5) + builder (~> 3.1) + coffee-rails (~> 4.0) + font-awesome-rails (>= 3.0, < 5) + haml (~> 4.0) + jquery-rails (~> 3.0) + jquery-ui-rails (~> 5.0) + kaminari (~> 0.14) + nested_form (~> 0.3) + rack-pjax (~> 0.7) + rails (~> 4.0) + remotipart (~> 1.0) + safe_yaml (~> 1.0) + sass-rails (~> 4.0) railties (4.1.8) actionpack (= 4.1.8) activesupport (= 4.1.8) @@ -134,6 +157,7 @@ GEM rake (10.4.2) rdoc (4.2.0) json (~> 1.4) + remotipart (1.2.1) responders (1.1.2) railties (>= 3.2, < 4.2) rspec-core (3.0.4) @@ -153,6 +177,7 @@ GEM rspec-support (~> 3.0.0) rspec-support (3.0.4) ruby-progressbar (1.7.0) + safe_yaml (1.0.4) sass (3.2.19) sass-rails (4.0.5) railties (>= 4.0.0, < 5.0) @@ -232,6 +257,7 @@ DEPENDENCIES questiongenerator rails (= 4.1.8) rails-assets-growl + rails_admin rspec-rails (~> 3.0.0) ruby-progressbar sass-rails (~> 4.0.3) diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb new file mode 100644 index 00000000..4ec5da91 --- /dev/null +++ b/config/initializers/rails_admin.rb @@ -0,0 +1,45 @@ +# workaround to get pagination right +if defined? WillPaginate + Kaminari.configure do |config| + config.page_method_name = :per_page_kaminari + end +end + +RailsAdmin.config do |config| + + config.main_app_name = ['justask', 'Kontrollzentrum'] + + ## == Authentication == + config.authenticate_with do + redirect_to main_app.root_path unless current_user.try :admin? + end + config.current_user_method(&:current_user) + + config.actions do + dashboard # mandatory + index # mandatory + new + export + bulk_delete + show + edit + delete + show_in_app + + ## With an audit adapter, you can add: + # history_index + # history_show + end + +=begin + config.included_models = %w[ + Answer + Comment + Inbox + Question + Relationship + Smile + User + ] +=end +end diff --git a/config/routes.rb b/config/routes.rb index a3fff9dc..f99b8c19 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do + mount RailsAdmin::Engine => '/justask_admin', as: 'rails_admin' get 'notifications/index' root 'static#index'