I’m new to this… so hopefully someone can help me.
I have a few objects… Property and Address and Landlord… where a
Property has an address and a landlord has an address also.
I’ve modelled this in the db with the properties table having an
address_id and the landlord table having an address id.
My rb looks like:
class Property < ActiveRecord::Base
class Address < ActiveRecord::Base
the controller looks like:
@property = Property.new(params[:property])
@property.address = Address.new(params[:address])
if @property.save flash[:notice] = 'Property was successfully created.' redirect_to :action => 'list' else render :action => 'new' end
@property = Property.find(params[:id])
@address = @property.address
@landlords = Landlord.find_all
the form to save:
<%= text_area 'property', 'description' %>
<%= text_field 'property', 'price' %>
<%= text_field 'property', 'receptionCount' %>
<%= text_field 'property', 'bedroomCount' %>
<%= text_field 'property', 'bathroomCount' %>
<%= datetime_select 'property', 'dateRegistered' %>
<%= text_field 'address', 'number' %>
Street Name 1
<%= text_field 'address', 'streetName1' %>
but this is chucking out errors looking for a property_id column on the
database table address.
I dunno… I come from a java background and it ‘feels’ a bit backward
that it should be doing this.
I think i’m probably missing something simple… so if anyone could even
point me in the right direction that would be great!
Thanks in advance.