Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Controller breaks when an action is named 'config'

#5534

Hi,

I spend some time to figure out that an action named 'config' breaks the whole controller. A cryptic exception is raised whenever you try to access any action on that controller. In my case it was:

undefined method `allow_forgery_protection' for nil:NilClass

activesupport (3.0.0) lib/active_support/whiny_nil.rb:48:in `method_missing'
activesupport (3.0.0) lib/active_support/configurable.rb:22:in `allow_forgery_protection'
actionpack (3.0.0) lib/action_controller/metal/request_forgery_protection.rb:120:in `protect_against_forgery?'
actionpack (3.0.0) lib/action_controller/metal/request_forgery_protection.rb:105:in `verified_request?'
actionpack (3.0.0) lib/action_controller/metal/request_forgery_protection.rb:96:in `verify_authenticity_token'
activesupport (3.0.0) lib/active_support/callbacks.rb:436:in `_run__3642780899113546055__process_action__3023371025821930858__callbacks'
activesupport (3.0.0) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
...

It would be great to get a warning or a better error message when an illegal action name is used.

I attached a test-case to demonstrate the issue.

Regards
Lars

Reported by Lars Kuhnt · September 2nd, 2010 @ 02:58 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • State changed from new to invalid
    • Importance changed from to Low

    abstract_controller/base.rb has following line

    require 'active_support/configurable'
    

    configurable provides a method called config which allows one to do things like

        #   require 'active_support/configurable'      
        #  
        #   class User
        #     include ActiveSupport::Configurable
        #   end 
        #
        #   user = User.new
        # 
        #   user.config.allowed_access = true
        #   user.config.level = 1
        #
        #   user.config.allowed_access # => true
        #   user.config.level          # => 1
    

    Since abstract_controller includes that module a config method is automatically created. If you have an action named 'config' then that would overrite this config and that's not good.

    Yes it should be documented.

    September 7th, 2010 @ 10:34 PM