While studying a Rails application I saw statements like:
parameter[:user_id]
params[:user_id]
params["userid"]
Can anyone tell me if there any major difference between them? Or, are all
fetching parameters only and can I use them interchangeably?
I don’t think this is something official. However there’s a
parametersmethod on the current request object. Seerequest.parametersin a controller action.Using the
params[:user_id]is the same as callingrequest.parameters[:user_id]. Alsoparams[:user_id]is the same asparams["user_id"]. See HashWithIndifferentAccess.I am not sure if that’s just a typo on your part, but
params[:user_id]andparams["userid"]are not the same, even withHashWithIndifferentAccess. The_won’t just go away so they can hold different values.