From 9c7645cc584b1907df114b164e4552350fed8370 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Wed, 1 Jan 2014 20:39:29 +0100 Subject: [PATCH] Rails upgrades --- Gemfile.lock | 120 +++++++++--------- .../cmtool/application_controller.rb | 1 + app/controllers/cmtool/pages_controller.rb | 9 +- app/controllers/cmtool/users_controller.rb | 10 +- app/views/cmtool/users/_form.html.haml | 18 ++- .../layouts/cmtool/application.html.slim | 4 +- config/initializers/devise.rb | 2 + 7 files changed, 91 insertions(+), 73 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fe8d53c..13369c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ GIT GIT remote: git://github.com/bterkuile/orm_adapter.git - revision: 48b9ce9aedd1fe9f6a0a011e737b7dd395d26155 + revision: e0b5f652c8d1eda8c0f6636f3b3d17d598603450 specs: orm_adapter (0.4.0) @@ -42,40 +42,40 @@ PATH GEM remote: http://rubygems.org/ specs: - actionmailer (4.0.0) - actionpack (= 4.0.0) - mail (~> 2.5.3) - actionpack (4.0.0) - activesupport (= 4.0.0) + actionmailer (4.0.2) + actionpack (= 4.0.2) + mail (~> 2.5.4) + actionpack (4.0.2) + activesupport (= 4.0.2) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.0) - activesupport (= 4.0.0) + activemodel (4.0.2) + activesupport (= 4.0.2) builder (~> 3.1.0) - activerecord (4.0.0) - activemodel (= 4.0.0) + activerecord (4.0.2) + activemodel (= 4.0.2) activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.0) + activesupport (= 4.0.2) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) - activesupport (4.0.0) + activesupport (4.0.2) i18n (~> 0.6, >= 0.6.4) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - arel (4.0.0) + arel (4.0.1) atomic (1.1.14) bcrypt-ruby (3.1.2) - bootstrap-sass (2.3.2.2) + bootstrap-sass (3.0.3.0) sass (~> 3.2) bourbon (3.1.8) sass (>= 3.2.0) thor builder (3.1.4) - capybara (2.1.0) + capybara (2.2.0) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -83,7 +83,7 @@ GEM xpath (~> 2.0) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.1) + cocaine (0.5.3) climate_control (>= 0.0.3, < 1.0) coffee-script (2.2.0) coffee-script-source @@ -94,7 +94,7 @@ GEM multi_json (~> 1.0) rest-client (~> 1.6.1) daemons (1.1.9) - devise (3.1.0) + devise (3.2.2) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) @@ -102,68 +102,68 @@ GEM warden (~> 1.2.3) devise_simply_stored (0.0.3) devise - diff-lcs (1.2.4) + diff-lcs (1.2.5) email_validator (1.4.0) activemodel erubis (2.7.0) eventmachine (1.0.3) - execjs (2.0.1) - factory_girl (4.2.0) + execjs (2.0.2) + factory_girl (4.3.0) activesupport (>= 3.0.0) - factory_girl_rails (4.2.1) - factory_girl (~> 4.2.0) + factory_girl_rails (4.3.0) + factory_girl (~> 4.3.0) railties (>= 3.0.0) - haml (4.0.3) + haml (4.0.4) tilt - haml-rails (0.4) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (>= 3.1, < 4.1) - railties (>= 3.1, < 4.1) + haml-rails (0.5.2) + actionpack (~> 4.0.1) + activesupport (~> 4.0.1) + haml (>= 3.1, < 5.0) + railties (~> 4.0.1) hike (1.2.3) - i18n (0.6.5) + i18n (0.6.9) jquery-rails (3.0.4) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.8.0) + json (1.8.1) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.25) - mini_portile (0.5.1) + mime-types (1.25.1) + mini_portile (0.5.2) minitest (4.7.5) - multi_json (1.8.0) - nokogiri (1.6.0) + multi_json (1.8.2) + nokogiri (1.6.1) mini_portile (~> 0.5.0) - paperclip (3.5.1) + paperclip (3.5.2) activemodel (>= 3.0.0) activesupport (>= 3.0.0) - cocaine (~> 0.5.0) + cocaine (~> 0.5.3) mime-types polyglot (0.3.3) rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (4.0.0) - actionmailer (= 4.0.0) - actionpack (= 4.0.0) - activerecord (= 4.0.0) - activesupport (= 4.0.0) + rails (4.0.2) + actionmailer (= 4.0.2) + actionpack (= 4.0.2) + activerecord (= 4.0.2) + activesupport (= 4.0.2) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0) + railties (= 4.0.2) sprockets-rails (~> 2.0.0) - railties (4.0.0) - actionpack (= 4.0.0) - activesupport (= 4.0.0) + railties (4.0.2) + actionpack (= 4.0.2) + activesupport (= 4.0.2) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.1.0) rest-client (1.6.7) mime-types (>= 1.16) - rspec-core (2.14.5) - rspec-expectations (2.14.2) + rspec-core (2.14.7) + rspec-expectations (2.14.4) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.3) + rspec-mocks (2.14.4) rspec-rails (2.14.0) actionpack (>= 3.0) activesupport (>= 3.0) @@ -171,46 +171,46 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - sass (3.2.10) - sass-rails (4.0.0) - railties (>= 4.0.0.beta, < 5.0) + sass (3.2.12) + sass-rails (4.0.1) + railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) sprockets-rails (~> 2.0.0) - slim (2.0.1) + slim (2.0.2) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) - slim-rails (2.0.1) + slim-rails (2.0.4) actionpack (>= 3.0, < 4.1) activesupport (>= 3.0, < 4.1) railties (>= 3.0, < 4.1) slim (~> 2.0) - sprockets (2.10.0) + sprockets (2.10.1) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.0) + sprockets-rails (2.0.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) steak (2.0.0) capybara (>= 1.0.0) rspec-rails (>= 2.5.0) - temple (0.6.6) - thin (1.5.1) + temple (0.6.7) + thin (1.6.1) daemons (>= 1.0.9) - eventmachine (>= 0.12.6) + eventmachine (>= 1.0.0) rack (>= 1.0.0) thor (0.18.1) thread_safe (0.1.3) atomic tilt (1.4.1) - tinymce-rails (4.0.6) + tinymce-rails (4.0.11) railties (>= 3.1.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.37) + tzinfo (0.3.38) warden (1.2.3) rack (>= 1.0) xpath (2.0.0) diff --git a/app/controllers/cmtool/application_controller.rb b/app/controllers/cmtool/application_controller.rb index 764ebab..2a84f74 100644 --- a/app/controllers/cmtool/application_controller.rb +++ b/app/controllers/cmtool/application_controller.rb @@ -1,6 +1,7 @@ module Cmtool class ApplicationController < ::ApplicationController before_filter :authenticate_user!, :authorize_user, :check_environment, :set_locale + layout 'cmtool/application' private diff --git a/app/controllers/cmtool/pages_controller.rb b/app/controllers/cmtool/pages_controller.rb index 1125bfe..e1e6c3f 100644 --- a/app/controllers/cmtool/pages_controller.rb +++ b/app/controllers/cmtool/pages_controller.rb @@ -41,7 +41,7 @@ module Cmtool # POST /pages # POST /pages.xml def create - @page = ::Page.new(params[:page]) + @page = ::Page.new(page_params) respond_to do |format| if @page.save @@ -60,7 +60,7 @@ module Cmtool @page = ::Page.find(params[:id]) respond_to do |format| - if @page.update_attributes(params[:page]) + if @page.update_attributes(page_params) format.html { redirect_to(cmtool.pages_path, :notice => I18n.t('cmtool.action.update.successful', :model => ::Page.model_name.human)) } format.xml { head :ok } else @@ -96,6 +96,11 @@ module Cmtool end + private + + def page_params + params.require(:page).permit! + end end end diff --git a/app/controllers/cmtool/users_controller.rb b/app/controllers/cmtool/users_controller.rb index c55878d..839fc2a 100644 --- a/app/controllers/cmtool/users_controller.rb +++ b/app/controllers/cmtool/users_controller.rb @@ -19,7 +19,7 @@ module Cmtool end def create - @user = ::User.new(params[:user]) + @user = ::User.new(user_params) if @user.save redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.create.successful', :model => ::User.model_name.human) else @@ -28,7 +28,7 @@ module Cmtool end def update - user = params[:user] + user = user_params unless user['password'].present? user.delete('password') user.delete('password_confirmation') @@ -50,5 +50,11 @@ module Cmtool @user.destroy redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.destroy.successful', :model => ::User.model_name.human) end + + private + + def user_params + params.require(:user).permit! + end end end diff --git a/app/views/cmtool/users/_form.html.haml b/app/views/cmtool/users/_form.html.haml index 92b144f..7b4b890 100644 --- a/app/views/cmtool/users/_form.html.haml +++ b/app/views/cmtool/users/_form.html.haml @@ -11,11 +11,17 @@ = f.label :password_confirmation = f.password_field :password_confirmation - if @user != current_user - .field - = f.label :active - = f.check_box :active - .field - = f.label :is_admin - = f.check_box :is_admin + - if @user.respond_to?(:active=) + .field + = f.label :active + = f.check_box :active + - if @user.respond_to?(:is_admin=) + .field + = f.label :is_admin + = f.check_box :is_admin + - if @user.respond_to?(:admin=) + .field + = f.label :admin + = f.check_box :admin .actions = f.submit @submit || update_button_text(@user) diff --git a/app/views/layouts/cmtool/application.html.slim b/app/views/layouts/cmtool/application.html.slim index f153d3a..63e32a2 100644 --- a/app/views/layouts/cmtool/application.html.slim +++ b/app/views/layouts/cmtool/application.html.slim @@ -40,7 +40,6 @@ html lang="en" = content_for?(:content) ? yield(:content) : yield - if content_for?(:page_links) #sub-navigation-container.form-actions = yield(:page_links) - .span3 .well.sidebar-nav h3= content_for?(:page_title) ? yield(:page_title) : application_title @@ -49,8 +48,7 @@ html lang="en" li= link_to "Home", root_path li= link_to 'Wiki', 'https://github.com/bterkuile/cmtool/wiki', target: :_blank = yield :sidebar - footer - p © Cmtool 2012 + p © Cmtool 2013 = yield :footer #hidden-html.hide= yield :hidden_html diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index a79c9c5..dd78ff4 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -1,5 +1,6 @@ # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. +=begin Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing @@ -256,3 +257,4 @@ Devise.setup do |config| # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = '/my_engine/users/auth' end +=end