Conditional options for Rails methods? -


i want add class form_for method, how that?

<% if @plan.price == 0 %>    <%= form_for @account, :html => { :class => 'new_account' } |f| %> <% else %>    <%= form_for @account, :html => { :class => 'new_account payment-form' } |f| %> <% end %> 

seems there's gotta more concise way pull off.

you this:

<%= form_for @account, html: { class: "new_account #{(@plan.price == 0) ? '' : 'payment-form'}" } |f| %> 

Comments

Popular posts from this blog

matlab - How to equate a structure array to structure array -

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -