Conditional action - if action = '' do this

hiya,

trying to work this out to build a dynamic sidebar,

i’ve got the sidebar in a partial, now wondering how to get different
elements to hide for certain actions…

e.g.

<% if action = ‘about’ %>
about logo
<% end %>

any ideas how you can run conditional parts based on the action you just
did, or should i set & call a variable instead?

appreciate it,

John.

params[:action]

sweet enough?
:slight_smile:

Hi –

On Wed, 8 Aug 2007, Shai R. wrote:

params[:action]

sweet enough?
:slight_smile:

Make sure to use == and not = though…

David

perfect…

<% if params[:action] == ‘about’ %>
code
<% end %>

you rock!

thanks, it suddenly struck me that i could this this another way.

you see i’ve got the main layout in…

layouts/application.rhtml

so by putting in a code to pull in a partial i could not specify the
controller to pull it from and then it would pull that partial from the
controller / view the actions sitting in then and there.

as long as i have the same named partial in each view, pretty sweet.

however thanks for the params[:action] should work out right, yep got
the == meaning check if identical.

thanks guys,