From 41536b086fa5cef3393afd01f622a1fddfe151e6 Mon Sep 17 00:00:00 2001 From: Collin Brittle Date: Tue, 7 Jul 2015 10:45:57 -0400 Subject: [PATCH] Remove outdated cancan fix. Comments on the fix suggest it is related to this bug in Cancan: https://github.com/ryanb/cancan/issues/835 The comments on that bug say it is fixed in Cancancan. --- README.md | 3 ++- lib/generators/roles/roles_generator.rb | 16 ---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 91b41bf..08f1aa3 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,5 @@ Given the need to support both Rails 3 and 4, the test suite has been parameteri * Set Rails version you want to test against. For example: * ```RAILS_VERSION=3.2.13``` or ```RAILS_VERSION=4.0.0``` * Ensure that the correct version of Rails is installed: ```bundle update``` -* Build test app and run tests: ```bundle exec rake spec``` +* Build test app: ```bundle exec engine_cart:generate``` +* And run tests: ```bundle exec rake spec``` diff --git a/lib/generators/roles/roles_generator.rb b/lib/generators/roles/roles_generator.rb index 3e3a982..babfd12 100644 --- a/lib/generators/roles/roles_generator.rb +++ b/lib/generators/roles/roles_generator.rb @@ -62,22 +62,6 @@ def inject_routes inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false } end - # As of 7.23.2013 cancan support for Rails 4 is weak and requires monkey-patching. - # More information can be found at https://github.com/ryanb/cancan/issues/835 - def rails4_application_controller_patch - if Rails::VERSION::MAJOR == 4 - puts "Adding before_filter to application_controller to help Cancan work with Rails 4." - file_path = "app/controllers/application_controller.rb" - code = "\n before_filter do" + - "\n resource = controller_path.singularize.gsub('/', '_').to_sym\n" + - ' method = "#{resource}_params"'+ - "\n params[resource] &&= send(method) if respond_to?(method, true)" + - "\n end" - - inject_into_file file_path, code, {after: 'class ApplicationController < ActionController::Base'} - end - end - # If this gem is installed under Rails 3, an attr_accessible method is required for the Role model. This # file will be added to config/initializers and the correct code will be added to the model at runtime. def rails3_attr_accessible