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: <% fields_for(@business.address) do |f| %>
22:   <%= render(:partial =>'new_address', :locals => {:f=>f}) %>
23: <% end %>
24:

RAILS_ROOT: C:/User/InstantRails/rails_apps/gofetch

Application Trace | Framework Trace | Full Trace
C:/User/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/
lib/active_record/attribute_methods.rb:205:in `method_missing'
app/views/businesses/new.html.erb:21:in
`_run_erb_47app47views47businesses47new46html46erb'
app/views/businesses/new.html.erb:5:in
`_run_erb_47app47views47businesses47new46html46erb'
app/controllers/businesses_controller.rb:29:in `new'



The relationship between the business, address and catogories is: a
business can only have one address but an address can have one or many
businesses, a business can have one or many categories and a category
can have one or many businesses.

I have already created the relationships and another table to
decompose the relationship between category and business. I'm actually
working on a final year project on how to adapt SCRUM to a one man
team, I have to use ruby on rails as my tutor says it works well with
this methodology, I don't have much technical aptitude with
programming but I'm pretty good with the SCRUM side of things. The
reason the model design may seem weird is that I was told to use
scaffolding and partials to create this part of the app.

On Feb 12, 12:29 pm, Sharagoz -- <[email protected]> wrote:
> 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) do |fields| %>
>     <p>
>       <b>Business name</b><br />
>       <%= fields.text_field :business_name %>
>     </p>
>
>     <p>
>       <b>Telephone</b><br />
>       <%= fields.text_field :telephone %>
>     </p>
>
>     <p>
>       <b>Website</b><br />
>       <%= fields.text_field :website %>
>     </p>
>
>   <% fields_for(@business.category) do |f| %>
>     <%= render(:partial => 'new_category', :locals => {:f => f}) %>
>   <% end %>
>
>   <% fields_for(@business.address) do |f| %>
>     <%= render(:partial => 'new_address', :locals => {:f => f}) %>
>   <% end %>
>
>   <%= fields.submit('Done') %>
> <% end %>
>
> The model design seems weired, but I guess you have your reasons.
> --
> Posted viahttp://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 protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to