Hi Paul,
thanks for your reply.
In my categories table I have some records: rooms, food, service etc.
my show.html.erb looks like this:
<h2>Hotel Ratings:</h2>
<% @hotel.ratings.each do |show| %>
<li><%= show.category.name %> <%= show.rating %>
<% end %>
For a hotel this gives me:
Hotel Ratings:
rooms 3
food 4
service 3
This part works fine. Now I would like to edit the Ratings.
In my hotel edit form I want to show each one of these categories with
a text_field behind it, so I can enter a rating.
<% form_for(@hotel) do |form| %>
...
<% form.fields_for :ratings do |rating_field| %>
<%= show me the hotel-rating-category names %> <%= rating_field
(s).text_field :rating %>
<% end %>
...
<% end %>
How do I loop through all my categories, show their names and enter a
value for each different category?
I hope this describes my problem a little better.
Probably I''m thinking much too complicated :-(
Regards
Arwed
On 12 Okt., 10:55, Samiron
<samironp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> > ...
> > <% if @hotel.categories.any? %>
> > <% @hotel.ratings.each do |rating| %>
> > <% fields_for @hotel.ratings do |rating_form| %>
> > <li><% rating.category.name %> <%
rating_form.text_field :rating
> > %></li>
> > <% end %>
> > <% end %>
> > ...
>
> As you told you are trying to edit hotel information. So I think you
> should have like following
> <% form_for(@hotel) do |form| %>
> <% end %>
>
> and inside this you might use like
> <% form.fields_for :ratings do |rating_field| %>
> # print rating fields
> <% end %>
>
> If the above doesnt help you, would you please provide more insight
> about what and how you are actually want to print ratings in hotel
> edit form?
>
> Thank you.
>
> Samiron paulhttp://samironpaul.blogspot.comhttp://www.code71.com