recipes/devise.rb in rails_apps_composer-1.4.5 vs recipes/devise.rb in rails_apps_composer-1.4.6

- old
+ new

@@ -18,13 +18,14 @@ else recipes.delete('devise') say_wizard "Devise recipe skipped." end -if config['canard'] - gem 'cancan', '>= 0.2.7' - recipes << 'canard' +if config['authorization'] + gem 'cancan', '>= 1.6.7' + gem 'rolify', '>= 3.1.0' + recipes << 'authorization' end if recipes.include? 'devise' after_bundler do @@ -49,12 +50,21 @@ if recipes.include? 'cucumber' # Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path # (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3) gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete' end - + + if config['authorization'] + inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY + rescue_from CanCan::AccessDenied do |exception| + redirect_to root_path, :error => exception.message end +RUBY + end + end + + end after_everything do say_wizard "Devise recipe running 'after everything'" @@ -97,8 +107,8 @@ config: - devise: type: multiple_choice prompt: Would you like to use Devise for authentication? choices: [["No", no], ["Devise with default modules", standard], ["Devise with Confirmable module", confirmable], ["Devise with Confirmable and Invitable modules", invitable]] - - canard: + - authorization: type: boolean - prompt: Would you like to manage authorization with CanCan, RoleModel, and Canard? + prompt: Would you like to manage authorization with CanCan & Rolify?