On 11/21/06, Jared [email protected] wrote:
In the partial, you’re dealing with a local variable (canbackground),
but in the full-blown show view, you’re dealing with an instance
variable (@canbackground).
Hope this helps!
It defintely helped getting canbackgrounds/show.rhtml to work.
However the link_to_remote is not working and it looks like the primary
resource @candidate , the id is not getting picked up.
ActiveRecord::RecordNotFound in CanbackgroundsController#show
Couldn’t find Candidate with ID=#Canbackground:0x80faed0
RAILS_ROOT: ./script/…/config/… Application
Tracehttp://localhost:3000/candidates/12/#| Framework
Trace http://localhost:3000/candidates/12/# | Full
Tracehttp://localhost:3000/candidates/12/#
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1027:in
find_one' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1010:in
find_from_ids’
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:416:in
find' #{RAILS_ROOT}/app/controllers/canbackgrounds_controller.rb:126:in
find_candidate’
Request
Parameters: {“candidate_id”=>“#Canbackground:0x80faed0”,
“id”=>“12”}
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1027:in
find_one' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1010:in
find_from_ids’
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:416:in
find' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:471:in
call’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:450:in
call' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:633:in
call_filter’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:634:in
call_filter' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:453:in
call’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:633:in
call_filter' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:634:in
call_filter’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:464:in
call' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:633:in
call_filter’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:615:in
perform_action_without_benchmark' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue’
C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/rescue.rb:81:in
perform_action' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:425:in
process_without_filters’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:620:in
process_without_session_management_support' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in
process’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:328:in
process' #{RAILS_ROOT}/vendor/rails/railties/lib/dispatcher.rb:41:in
dispatch’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in
process' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:551:in
process_client’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in
process_client' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:956:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:127:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:357:in
load' #{RAILS_ROOT}/vendor/rails/railties/lib/commands/servers/mongrel.rb:48 C:/INSTAN~1/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require’
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:364:in
`require’
#{RAILS_ROOT}/vendor/rails/railties/lib/commands/server.rb:39
script/server:3
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1027:in
find_one' #{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1010:in
find_from_ids’
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:416:in
find' #{RAILS_ROOT}/app/controllers/canbackgrounds_controller.rb:126:in
find_candidate’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:471:in
call' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:450:in
call’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:633:in
call_filter' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:634:in
call_filter’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:453:in
call' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:633:in
call_filter’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:634:in
call_filter' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:464:in
call’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:633:in
call_filter' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:615:in
perform_action_without_benchmark’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in
measure’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in
perform_action_without_rescue' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/rescue.rb:81:in
perform_action’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:425:in
process_without_filters' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:620:in
process_without_session_management_support’
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in
process' #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:328:in
process’
#{RAILS_ROOT}/vendor/rails/railties/lib/dispatcher.rb:41:in dispatch' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/rails.rb:73:in
process’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:551:in
process_client' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:550:in
process_client’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:636:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:625:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:956:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel.rb:955:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:127:in
run’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in
run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235 #{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:357:in
load’
#{RAILS_ROOT}/vendor/rails/railties/lib/commands/servers/mongrel.rb:48
C:/INSTAN~1/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' #{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:364:in
require’
#{RAILS_ROOT}/vendor/rails/railties/lib/commands/server.rb:39
script/server:3
To show , I have a before_filter in my canbackgrounds controller , I’ve
tried both using it and making an exception for the show action.
Neither
way is working.
canbackgrounds.rb controller excerpts:
before_filter :find_candidate
private
def find_candidate
@candidate_id = params[:candidate_id]
redirect_to candidate_url unless @candidate_id
@candidate = Candidate.find(@candidate_id)
end
This is where it seems to be dying as show in the error above.
I tried adding candidate_id => candidate.id to the URL hash but just
thrown
an error.
Stuart