SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    chapter 5 problem (and earlier, pg 140)

    It started the same as this post: http://www.sitepoint.com/forums/showthread.php?t=531057

    so i did the script/destroy on my model/controller. Then ran:
    $ script/generate scaffold Contact name:string email:string

    Then i figured i needed my controller again so i ran the controller:
    $ script/generate controller Story

    So i try and see the page via: script/server

    and i get:
    Routing Error

    No route matches "/story" with {:method=>:get}

    I know this has been done improperlly now but I really do not know where to start again (how do i get rid of EVERYTHING properly to start fresh?). What do i run and what should i not run when i restart ?

    This is all new to me, so now following a book which is out of date is becoming troublesome.


    (the book just incase there more than one is "Build Your Own Ruby on Rails Web Applications")
    Thanks for the help in advance.
    -brianp

  2. #2
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    update

    Hey,

    So this morning i re-created by rails project.

    Edited my db.yml

    ran:
    Code:
    script/generate scaffold Story name:string link:string
    and got the same error:
    Routing Error

    No route matches "/story/" with {:method=>:get}
    (at uri: http://localhost:3000/story)

    after some looking into different files i found uri http://localhost:3000/stories/ worked like i wanted it too. But what do i do if the controller is supposed to be called Story, and not stories ?

  3. #3
    l 0 l silver trophybronze trophy lo0ol's Avatar
    Join Date
    Aug 2002
    Location
    Palo Alto
    Posts
    5,329
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If you're using Rails 2.0, the default scaffold expects to pluralize your controllers (which is the RESTful way of doing things). That's why you get stories, not story. If you look at your config/routes.rb file, your route is probably set up as map.resources :stories.

    To be honest, I'd try to stick with the plural controller form. That just seems the way that Rails expects things nowadays, and it's not going to be changing any time soon. If you look into REST and how Rails leverages it, it really starts to make sense, too.


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
  •