Results 1 to 22 of 22
Thread: Simply Rails problem on page 207
Aug 7, 2008, 19:06 #1
- Join Date
- Aug 2008
- 0 Post(s)
- 0 Thread(s)
Simply Rails problem on page 207
Sorry, I posted this on Questions, then realized I should have posted it here. I started this forum today.
I am new to Rails.
When I browse to localhost:3000/stories, —it works.
When I browse to localhost:3000/stories/2
I get a NoMethodError showing stories/show.html.erb that says "You have a nil object when you didn't expect it! The error occured while evaluating nil.name"
The Extracted Source is
1: <h2><%= @story.name %></h2>
2: <p><%= link_to @story.link, @story.link %></p>
(which is from show.html.erb)
class StoriesController < ApplicationController
@story = Story.find(:first, :order => 'RANDOM()')
@story = Story.new
@story = Story.new(params[:story])
flash[:notice] = "Story submission succeeded"
render :action => 'new'
@story = Story.find(params[:id])
Can anyone help?