Forum: Ruby on Rails basic usage confusion

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-02-06 08:00
(Received via mailing list)
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' 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?

Steven S. (Guest)
on 2006-02-06 08:16
(Received via mailing list)
You might try changing the problematic line as follows:

	<%= @placement.referral_date %>
anne g (Guest)
on 2006-02-06 13:21
(Received via mailing list)
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 topic is locked and can not be replied to.