You are confusing things a lot. Answer this question first: Did you scaffold the model or you are adding the files one by one writing the code by hand.
1. If you did scaffold, I don't see a problem coming anywhere. 2. If you didn't scaffold, then go for Colin's suggestion and read the guides, you will understand how Rails works. AND read the guides rightnow, before you get troubled by another problem. As of the current problem that you are facing, do this: 1. Look up the database table for posts, and see if you have a column named 'name' in there. If not, what went wrong. 2. I am quite sure, 1st would fail. Now, look up your post.rb model file and see if there is attr_accessible : name in your model file. On Sun, May 22, 2011 at 9:53 PM, John shelfer <[email protected]>wrote: > > > On May 22, 3:15 am, Colin Law <[email protected]> wrote: > > On 22 May 2011 08:09, John shelfer <[email protected]> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > On May 22, 2:55 am, Colin Law <[email protected]> wrote: > > >> On 22 May 2011 07:41, John shelfer <[email protected]> wrote: > > >>> ... > > >> > "undefined method `name' for #<Post id: nil, created_at: nil, > > >> > updated_at: nil>" > > > > >> Look at the error and try and work out what it means. There should > > >> also be an indication of which line generated the error. > > > Error is generated at link 8 in following code. > > > > > <%= link_to 'New Post', new_post_path%> > > > <%= form_for(@post) do |f| %> > > > > > <div class="field"> > > > <%= f.label :name %><br /> > > > <%= f.text_field :name %> > > > > Here you are asking to display (and allow entry) of @post.name, > > whereas the error suggests that Post does not have a method 'name'. > 'name' is field that i want to generate in form.Let me tell you i > have total 3 files > > 1)posts_controller.rb(code is above) > > 2)try.html.erb(/view/posts)(code is above) > > 3)post.rb(Model)(Empty) > > John > > -- > 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. > > -- 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.

