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…


Processing PlacementsController#rfn2 (for at 2006-02-05
22:44:55) [GET]
Parameters: {“action”=>“rfn2”, “id”=>“4”, “controller”=>“placements”}
Placement Load (0.010998) SELECT * FROM placements WHERE
( = ‘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
8: <%= debug params %>
9: <%= params.inspect %>
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])

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?


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

maybe side to side we can understand what is goin on

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs