Select 'others' Option From Drop Down List Creating Text Field Ruby On Rails - 4.2
_form.html.erb
<%= f.label :description %><%= f.select(:description, options_for_select([['', ''],['METRO', 'METRO'], ['BUS'
Solution 1:
Found it - I'm kind of blind sometimes...
index.html.erb
<td class="col-1"><%= expense.description %> <%= link_to expense.description_other,{}, {:style =>'color: #CC3366'} %></td>
You've got two <%= ... %>
's in there ...
<%= expense.description %>
And then
<%= link_to expense.description_other,{}, {:style => 'color: #CC3366'} %>
Get ride of the first one when OTHER
is selected, using an if conditional(the trinary operator we talked about <expression> ? <if true do this happens>: <if false this happens>
The conditional would have to contain both statements inside one <%= ... %>
block.
Also, you have an issue here ... should have a conditional of some sort ... probably the ||=
& drop the Expense.new or the Expense.last.dup
defnew@expense = Expense.new
@expense = Expense.last.dup
end
Post a Comment for "Select 'others' Option From Drop Down List Creating Text Field Ruby On Rails - 4.2"