SitePoint Sponsor

User Tag List

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

    Can't get link to display in view (Chapter 5)

    I can't get the link to display as in Figure 5.11 of the book. In this illustration, it should display the text, and a link.

    I have gone through my code for the controller, and for the view, but can't find the problem. Would appreciate it if you could have a look and tell me what's wrong.

    Following is the code for the controller:
    Code:
    class StoryController < ApplicationController
      def index
        @story = Story.find(:first, :order=>'RAND()')
      end
    end
    Here is the code for the index.rhtml in the view:
    Code:
    A random link:
    <%= link_to @story.name, @story.link %>
    Thanks in advance...

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is @story.link?

    Your code is ok (if stories have an @story.name). What do see on the page and what do you want to see?


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
  •