SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply Rails 2: Stuck @pg 164

    Hi people,

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

    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 ?

    Code:
    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/..

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    Code:
    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:
    Code:
    <%= f.text_field :another %>
    Can be commented out by putting a hash between the percentage and equals signs:
    Code:
    <%#= f.text_field :another %>
    That will tell us whether this problem is specific to the form_for method.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Location
    Cleveland, OH
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi guys !

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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •