0
votes

I've created two models, one is bar, one is special. I've created a dropdown box in my new special view file that I want to display bars. Here is my code.

<%= form_for(@special) do |f| %>
<% if @special.errors.any? %>
<div id="error_explanation">
  <h2><%= pluralize(@special.errors.count, "error") %> prohibited this special from being saved:</h2>
   <ul>
   <% @special.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>      <% end %>
  </ul>
</div>
<% end %>
<div class="field">
  <%= f.label :special %><br />
  <%= f.text_field :special %> 
 </div>
 <div class="field">
 <%= f.collection_select(:special, :bar_id, Bar.all, :id, :name, :prompt => "Select a bar" %>  
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

Sorry for the poor formatting above. What I get when I run this code is this:

Showing D:/DevProjects/tapadeal/app/views/specials/_form.html.erb where line #24 raised:

D:/DevProjects/tapadeal/app/views/specials/_form.html.erb:24: syntax error, unexpected keyword_end, expecting ')' '); end ^ D:/DevProjects/tapadeal/app/views/specials/_form.html.erb:26: syntax error, unexpected keyword_ensure, expecting ')' D:/DevProjects/tapadeal/app/views/specials/_form.html.erb:28: syntax error, unexpected keyword_end, expecting ')' Extracted source (around line #24):

Extracted source (around line #24):

21: div class="actions"

22: <%= f.submit %>

23: /div

24: <% end %>

Any ideas or suggestions would be greatly appreciated.

1

1 Answers

0
votes

Try closing your parentheses:

 <%= f.collection_select(:special, :bar_id, Bar.all, :id, :name, :prompt => "Select a bar") %>