SitePoint Sponsor

User Tag List

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

    Rails: undefined method `scaffold' for StoryController:Class

    I have a copy of the Rails 1 book. I realize that it is from 2007, and that the Rails 2 book has come out. From what I can tell, the same error applies in the newer version of the book too. I have found several errors so far, but have googled and corrected them all and am currently on page 139. Here is a break down of the problem.

    As the book instructed on page 140 I changed story_controller.rb to
    Code:
    class StoryController < ApplicationController 
       scaffold :story
    end
    When I then went to http://localhost:3000/story I got:
    Routing Error

    undefined method `scaffold' for StoryController:Class

    I googled that and found another thread on this forum, here: http://www.sitepoint.com/forums/showthread.php?t=531057

    There it was recommended that I read http://www.leonardoborges.com/writings/2007/12/21/rails-20-scaffold/
    which I did.

    That explain that we are supposed to now be using:
    Code:
    rails generate scaffold Story name:string email:string
    I am still getting the error:
    Routing Error

    undefined method `scaffold' for StoryController:Class

    Please help me out. I would like to keep moving forward. I can tell that I am learning, but I don't know enough to get over this hurdle. Thanks!!!

  2. #2
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been playing around with so many things, trying to do things different ways. This might be the answer. I am not even sure. Check the answer in this thread: http://www.sitepoint.com/forums/show....php?p=3763620

    If someone else reads this, and knows for sure that this ISN'T the answer, please reply.

    Thanks!

  3. #3
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Scaffolds in rails are just a way to create views directly from a model and you should not use this in all of your models. Because you need to learn how things work in rails such as how routes, views, model and controller are working together.

    I recommended to use ryan bates nifty_generators https://github.com/ryanb/nifty-generators

  4. #4
    Team ********* Louis Simoneau's Avatar
    Join Date
    Sep 2009
    Location
    Melbourne, Australia
    Posts
    228
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi. The Rails Guides have a good section on scaffolding and the resulting routes that explains everything pretty clearly: http://guides.rubyonrails.org/gettin...th-scaffolding


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
  •