Simply Rails 2: Stuck @pg 164

Hi people,

Im new to programming & ruby so be patient with me. :slight_smile:

I got stuck at pg 164 after doing the mapping of the new resource. I got a “Naming Error”

anybody can point me to look in some direction ?


NameError in Stories#new

Showing app/views/stories/new.rhtml where line #4 raised:

`@#<Story:0x256a638>' is not allowed as an instance variable name
Extracted source (around line #4):

1: <% form_for @story do |f| %>
2: <p>
3: 	name:<br />
4: 	<%= f.text_field :name %>
5: </p>
6: <p>
7: 	link:<br />
RAILS_ROOT: ./script/../config/..


What do you get if you use form_tag instead of form_for? You’ll need to alter the synax of your form a little. For example


1: <&#37; form_tag do %>
2: <p>
3: 	name:<br />
4: 	<%= text_field(:story, :name) %>
5: </p>
6: <p>
7: 	link:<br />

For this test you could comment out the other form elements if you don’t want to modify them too:


<%= f.text_field :another %>

Can be commented out by putting a hash between the percentage and equals signs:


<%#= f.text_field :another %>

That will tell us whether this problem is specific to the form_for method.

Can you check the version of Rails you are on? To do this go to your command line and use the rails -v command.

I’m asking because I see that your template file has the rhtml instead of html.erb extension, which may indicate you are using an older version of Rails.

hi guys !

kmsolorio was right, its the rails version. good eye on catching it!