On 27 May 2011 18:24, Caroline M. <[email protected]> wrote:
> ...
> now surprise surprise ive encountered another problem after i did above
> changes. ok so my index view now works perfectly in user_products
> controller.but when i click on create new product an error pops up. it
> was working fine, so dunno why a problem is caused now.unless ive done
> something stupid again. ive put whats showing up in the attached pdf.
> not sure what else to show you..i tried changing @product to
> @current_user.product but that didn't help. :/
> thanks for your time and patience!!
>
> Attachments:
> http://www.ruby-forum.com/attachment/6246/error.pdf

You could just have pasted it all here.  Including the complete error
and stack frame is ok.

undefined method `model_name' for NilClass:Class
Extracted source (around line #1):
1: <%= form_for(@product, :html => { :multipart => true }) do |f| %>

The clue is in the message, it is saying something is nil and the code
is asking for a method to be called on it.  The problem is probably
that @product is nil.  Assuming that @product is setup by a find call
on the database then it did not find a matching record for some reason
(or perhaps the code does not include a find at all).

As well as working through the tutorial have a look at the Rails Guide
on debugging.  It will show you how to use ruby-debug to break into
your code and inspect data and follow flow, which can be invaluable if
you cannot see the error by inspection.  Also have a look at
log/development.log in your app, it contains details of the actions
called and the parameters and also the database queries called which
can be invaluable when something is not working.

Colin

-- 
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