I have been working on a project based on Michael Hartl's book Ruby on
Rails Tutorial in order to try to teach myself Ruby on Rails. However,
when it tries to render a form designed to allow a user to submit a
small message, I get an error saying, "undefined method `model_name' for
NilClass:Class". It says the error is at line 1, which is "<%= form_for
@micropost do |f| %>". I have the following defined in
app/controllers/microposts_controller.rb:

  def new
    @micropost = Micropost.new
  end

I would have expected this code to create a blank Micropost object that
gets passed to form_for, but that doesn't seem to be what happened. I
attached a few files for reference.

Attachments:
http://www.ruby-forum.com/attachment/7609/microposts_controller.rb
http://www.ruby-forum.com/attachment/7610/_micropost_form.html.erb


-- 
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-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to