Forum: Ruby on Rails basic usage confusion

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-06 07: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...

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
4353600bbb6b6e0950e62f7f44e49dd5?d=identicon&s=25 Steven Smith (Guest)
on 2006-02-06 07:16
(Received via mailing list)
You might try changing the problematic line as follows:

	<%= @placement.referral_date %>
E29eaefee1709918198c8a4f55c42667?d=identicon&s=25 anne g (Guest)
on 2006-02-06 12: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
work?

maybe side to side we can understand what is goin on
This topic is locked and can not be replied to.