still cant get around this associations thing.
I have 2 models, a Hotel (created by scaffolding) and Facility.
The point is to associate a facility to a hotel, but since my facility
table has all the columns it needs with boolean type), a row in that
table would do for one hotel.
The thing is, I can't get it to show, and save/edit/update de
facilities. I've created a hotel_id colum when creating the model
Facility. My code is:
class Facility < ActiveRecord::Base
attr_accessible :concierge, :hotel_id, :room24h
class Hotel < ActiveRecord::Base
has_one :facility, :dependent => :destroy
accepts_nested_attributes_for :facility, :allow_destroy => true
attr_accessible :name, :rating, :recommended, :facility_attributes
The controllers for de facility are empty and the hotel are stock from
My form in the view is:
<%= form_for(@hotel) do |f| %>
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.label :rating %><br />
<%= f.number_field :rating %>
<%= f.label :recommended %><br />
<%= f.check_box :recommended %>
<%= f.fields_for :facility do |facility_fields| %>
<%= facility_fields.label :room24h, "24h Room Service:" %>
<%= facility_fields.check_box :room24h %>
<%= facility_fields.label "Concierge:" %>
<%= facility_fields.check_box :concierge %>
<%= f.submit %>
Something is probably missing in the hotels.controller but I've tried
and it still isn't displaying anything. What could it be? Thanks in
advance and sorry for the long post
Posted via http://www.ruby-forum.com/.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.