SitePoint Sponsor

User Tag List

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

    Experiencing permalink problem in Lenz's book

    Hello,

    I am in the "Showing off our Stories" section on page 198 in Lenz's book.

    When I enter this url http://localhost:3000/story/show/my-shiny-weblog I get the correct page.

    After the previous code and test I added:

    <%= link_to @story.name,
    story_url( ermalink => @story.permalink) %> (I don't know why a smilie icon shows up at these places)

    to the index.rhtml page and got an error page after browsing to http://localhost:3000/story/

    Instead of getting:
    Shovell
    A random link: Sitepont Forums,

    I got:

    ActionController::RoutingError in Story#index
    Showing app/views/story/index.rhtml where line #3 raised:

    story_url failed to generate from {:action=>"show", :controller=>"story", ermalink=>nil}, expected: {:controller=>"story", :action=>"show"}, diff: {ermalink=>nil} (I don't know why a smilie icon shows up at these places)

    Extracted source (around line #3):

    1: A random link:
    2: <%= link_to @story.name,
    3: story_url( ermalink => @story.permalink) %> (I don't know why a smilie icon shows up at these places)


    RAILS_ROOT: ./script/../config/..

    Application Trace | Framework Trace | Full Trace
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/routing.rb:1306:in `raise_named_route_error'
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/routing.rb:1278:in `generate'
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/url_rewriter.rb:107:in `rewrite_path'
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/url_rewriter.rb:70:in `rewrite'
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_controller/base.rb:527:in `url_for'
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_view/helpers/url_helper.rb:27:in `send'
    C:/InstantRails/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5/lib/action_view/helpers/url_helper.rb:27:in `url_for'
    (eval):19:in `story_url'
    C:/InstantRails/InstantRails/rails_apps/shovell/app/views/story/index.rhtml:3:in `_run_rhtml_47app47views47story47index46rhtml'

    But A funny thing happens. When I click the refresh button 4 or 5 times the correct page displays.

    Am I missing something. Is there some way to fix this? Your help would be much appreciated.

    Thanks,
    Walter
    Code HTML4Strict:
     

  2. #2
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Man,

    I can shed some light on this. This is because the book doesn't mention that the database entries need to be updated with the permalinks. I am not sure if this was intentional (to get users to go in, and attempt some ruby code themselves) or just mistake.

    If you want to just keep going, just enter your database and add some permalinks in the db, and you'll be on your way.

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    andrewkelly,

    Thanks for the answer. I had more than one name in the database but just a permalink on one record. I added the permalinks for the rest of them and that fixed the problem. Thanks again.

    Walter


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
  •