[Rails] Re: Amending partials

2010-02-18 Thread Sam
I have changed my models after you pointed out they were wrong: class Business ActiveRecord::Base belongs_to :address has_many :types has_many :categories, :through = :types end class Address ActiveRecord::Base has_many :businesses end class Category ActiveRecord::Base

[Rails] Re: Amending partials

2010-02-16 Thread Sam
class Business ActiveRecord::Base has_many :addresses has_and_belongs_to_many :categories validates_presence_of :business_name end class Category ActiveRecord::Base has_and_belongs_to_many :businesses validates_presence_of :category end class Address

[Rails] Re: Amending partials

2010-02-16 Thread Sharagoz --
In your previous post you said this: a business can only have one address but an address can have one or many businesses Your models are then set up wrong. They should be: class Business belongs_to :address class Address has_many :businesses A tip: validates_presence_of :street_name

Re: [Rails] Re: Amending partials

2010-02-16 Thread Colin Law
On 16 February 2010 10:32, Sam samir_ode...@hotmail.co.uk wrote: class Business ActiveRecord::Base        has_many :addresses        has_and_belongs_to_many :categories        validates_presence_of :business_name end class Category ActiveRecord::Base        has_and_belongs_to_many

[Rails] Re: Amending partials

2010-02-12 Thread Sam
Hi thanks for the info. Here is the link containing the code and an image of the form: https://gist.github.com/a3676da061799ac6e29d On Feb 11, 11:34 am, Sharagoz -- li...@ruby-forum.com wrote: If the code is too long to copy/paste directly into the post, then you can create a public gist on

[Rails] Re: Amending partials

2010-02-12 Thread Sharagoz --
Here's what you can do: First, edit all the form partials and remove the form tags so that only the fields are left. I dont know what the relationship between the models are. Is it business has one category and has one address? If so, the form would look something like: % form_for(@business)

[Rails] Re: Amending partials

2010-02-12 Thread Sam
I tried the code and I get the following error message: NoMethodError in Businesses#new Showing businesses/new.html.erb where line #21 raised: undefined method `address' for #Business:0x3220350 Extracted source (around line #21): 18: %= f.text_field :website % 19: /p 20: 21: %

[Rails] Re: Amending partials

2010-02-12 Thread Sharagoz --
Can you show us how the model associations for Business, Address and Category? E.G: class Address ActiveRecord::Base has_many :businesses end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group.

[Rails] Re: Amending partials

2010-02-11 Thread Sam
Thanks for replying, I'd like to post an image but Iseem to be having a few issues posting the link on here, I used image shack to upload the image of the form but I cannot post the direct link or embedded link, i keep getting an error message saying We were unable to post your message. Not sure

[Rails] Re: Amending partials

2010-02-11 Thread Sharagoz --
If the code is too long to copy/paste directly into the post, then you can create a public gist on github and link to that: http://gist.github.com/ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk

[Rails] Re: Amending partials

2010-02-10 Thread Sharagoz --
It would help if you show us the form(s) -- 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 rubyonrails-t...@googlegroups.com. To unsubscribe from this group,