Wednesday, 15 September 2010

ruby on rails - create a link with parameters, but show param only if condition occurs -



ruby on rails - create a link with parameters, but show param only if condition occurs -

how can create link_to , have param in url if status occurs?

for example, want have someurl.com/1111?foo=clown

but foo should there if status true.

if not, should just: someurl.com/1111

<%= link_to 'my link', your_path(:foo => ("clown" if your_condition)) %>

in exemple, :param equals "clown" if your_condition true, else :param nil , if param nil, ruby don't consider there parameter , ignore it.

ruby-on-rails

No comments:

Post a Comment