<%= params[:action] %>
and
<%= params['action'] %>
display
index
but what is the difference between this syntax?
See Question&Answers more detail:os<%= params[:action] %>
and
<%= params['action'] %>
display
index
but what is the difference between this syntax?
See Question&Answers more detail:osIn Rails, the params
hash is actually a HashWithIndifferentAccess
rather than a standard ruby Hash
object. This allows you to use either strings like 'action'
or symbols like :action
to access the contents.
You will get the same results regardless of what you use, but keep in mind this only works on HashWithIndifferentAccess
objects.