Basic usage confusion

I am confused. Looking at ‘list’ from scaffold, I see a record and click
the ‘show’ button. I put in a ‘link’ at the bottom of ‘show.rhtml’ to my
‘view’ rfn2.rhtml - action = ‘rfn2’, :id = @placement

I click this link and get error…

log/development.log

Processing PlacementsController#rfn2 (for 127.0.0.1 at 2006-02-05
22:44:55) [GET]
Parameters: {“action”=>“rfn2”, “id”=>“4”, “controller”=>“placements”}
Placement Load (0.010998) SELECT * FROM placements WHERE
(placements.id = ‘4’) LIMIT 1
Rendering within layouts/placements
Rendering placements/rfn2

ActionView::TemplateError (undefined local variable or method
`placement’ for #<#Class:0xb78874a8:0xb7887124>) on line #11 of
app/views/placements/rfn2.rhtml:
8: <%= debug params %>
9: <%= params.inspect %>
10:
11: <%= placement.referral_date %>

which of course is the line in rfn2.rhtml that is causing the problem.

placements_controller.rb has…

def rfn2
@placement = Placement.find(params[:id])
end

just like def edit and if I click on the ‘edit’ link…no problem…I
get the edit.rhtml with ‘id’ = “4”

Obviously, rfn2 knows I am wanting ‘id’ = ‘4’ but I get the ‘undefined
local variable or method’ error.

And there definitely is a column ‘referral_date’ in placements table.

Why do I get this error?

Craig

You might try changing the problematic line as follows:

<%= @placement.referral_date %>

Could you copy the def that works with the code to redirect that works,

and then

the def that does not work, with the code to redirect that does not
work?

maybe side to side we can understand what is goin on