Results 1 to 17 of 17
Jul 3, 2008, 23:36 #1
- Join Date
- Jul 2008
- 0 Post(s)
- 0 Thread(s)
Lenz book - Chapter 7 - Page 199... HELP.
I am getting an error... I am using Ruby 1.8.4, Rails 2.1.0.
NoMethodError in Story#show Showing story/show.rhtml where line #1 raised: You have a nil object when you didn't expect it! The error occurred while evaluating nil.name Extracted source (around line #1): 1: <h2><%= @story.name %></h2> 2: <p><%= link_to @story.link, @story.link %></p>
I have ensured that the permalinks exist... It's driving me NUTS.
class StoryController < ApplicationController skip_before_filter :verify_authenticity_token def show @story = Story.find_by_permalink(params[:permalink]) end def index @story = Story.find(:first, :order => 'RAND()') end def new @story = Story.new(params[:story]) if request.post? and @story.save flash[:notice] = 'Story submitted!' redirect_to :action => 'index' end end end
Okay, I even resorted to copying and pasting from the code archive. I AM FULL OF FAIL. Bleh. It didn't work. Perhaps the problem is with Rails 2.1.0. ???
What... The... F --
It works now... ? I just had to restart WEBrick.
Whatever, eh? Mods, delete this thread whenever... Sorry.
Last edited by grenadier42; Jul 4, 2008 at 00:23.