[katello-devel] RoR: Interesting difference between params[:action] and self.action_name

Ivan Nečas inecas at redhat.com
Wed Sep 14 12:29:04 UTC 2011


Hi there,

Regarding to BZ [1] was discovered interesting (in negative meaning of 
this word) difference between params[:action] and 
controller.action_name, which is good to know about.

In router we had the following code:

match '/consumers' =>  'systems#activate', :via =>  :post, :constraints =>  RegisterWithActivationKeyContraint.new
resources :consumers, :controller =>  'systems'

Although the constraint was evaluated false, the params[:action] was set to
"activate". action_name was correctly set to "create"

Rails guides [2] also discourage from using params[:action] if favour of action_name, unfortunately without explaining the reason.

[1] - https://bugzilla.redhat.com/show_bug.cgi?id=738200
[2] - http://guides.rubyonrails.org/action_controller_overview.html#routing-parameters


-- Ivan




More information about the katello-devel mailing list