I have a simple RoR project where I have a table (Story) with stories and links. I added a 3rd param in another table (permalink) and linked it. Now I want to access the records from Story using the permalink In the console I can do the following:>> s = Story.find_by_permalink("weblog")=> #<Story id: 1, name: "my weblog", link: "http://mywelog.com", created_at: "2008-01-06 02:25:36", updated_at: "2008-01-12 19:29:41", permalink: "weblog"> this is the result I was expecting. Now moving on to the controller, I have in there: def show @story = Story.find_by_permalink(params[:permalink]) end and in the view I have: <p> My Story </p> <h2><%= @story.name %></h2> <p><%= link_to @story.link, @story.link %></p> I also updated the routes.rb file, adding in there: map.story ''story/show/:permalink'', :controller => ''story'', :action => ''show'' Now when I run the server, and type in: http://localhost:3000/story/show/weblog I get the following error: NoMethodError in Story#show Showing story/show.rhtml where line #2 raised: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.name Extracted source (around line #2): 1: <p> My Story </p> 2: <h2><%= @story.name %></h2> 3: <p><%= link_to @story.link, @story.link %></p> RAILS_ROOT: /home/hkhan/digg Application Trace | Framework Trace | Full Trace app/views/story/show.rhtml:2:in `_run_erb_47app47views47story47show46rhtml'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:836:in `render_with_no_layout'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:262:in `render_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1153:in `default_render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1159:in `perform_action_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' script/server:3 app/views/story/show.rhtml:2:in `_run_erb_47app47views47story47show46rhtml'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:836:in `render_with_no_layout'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:262:in `render_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1153:in `default_render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1159:in `perform_action_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' script/server:3 Request Parameters: {"id"=>"weblog"} Show session dump --- :csrf_id: d13a9d7dbf67db04912fb3bdfe1dc0bc flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} Any ideas????? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have a simple RoR project where I have a table (Story) with stories and links. I added a 3rd param in another table (permalink) and linked it. Now I want to access the records from Story using the permalink In the console I can do the following:>> s = Story.find_by_permalink("weblog")=> #<Story id: 1, name: "my weblog", link: "http://mywelog.com", created_at: "2008-01-06 02:25:36", updated_at: "2008-01-12 19:29:41", permalink: "weblog"> this is the result I was expecting. Now moving on to the controller, I have in there: def show @story = Story.find_by_permalink(params[:permalink]) end and in the view I have: <p> My Story </p> <h2><%= @story.name %></h2> <p><%= link_to @story.link, @story.link %></p> I also updated the routes.rb file, adding in there: map.story ''story/show/:permalink'', :controller => ''story'', :action => ''show'' Now when I run the server, and type in: http://localhost:3000/story/show/weblog I get the following error: NoMethodError in Story#show Showing story/show.rhtml where line #2 raised: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.name Extracted source (around line #2): 1: <p> My Story </p> 2: <h2><%= @story.name %></h2> 3: <p><%= link_to @story.link, @story.link %></p> RAILS_ROOT: /home/hkhan/digg Application Trace | Framework Trace | Full Trace app/views/story/show.rhtml:2:in `_run_erb_47app47views47story47show46rhtml'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:836:in `render_with_no_layout'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:262:in `render_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1153:in `default_render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1159:in `perform_action_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' script/server:3 app/views/story/show.rhtml:2:in `_run_erb_47app47views47story47show46rhtml'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:836:in `render_with_no_layout'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:262:in `render_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1153:in `default_render'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1159:in `perform_action_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'' /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'' /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' script/server:3 Request Parameters: {"id"=>"weblog"} Show session dump --- :csrf_id: d13a9d7dbf67db04912fb3bdfe1dc0bc flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} But if I change the controller to: def show #@story = Story.find_by_permalink(params[:permalink]) @story = Story.find_by_id(params[:id]) end and then do: http://localhost:3000/story/show/1 Then I get the correct output. Any ideas????? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> def show > @story = Story.find_by_permalink(params[:permalink]) > endI´ve had the same problem and solved it by using: def show @story = Story.find_by_permalink(params[:id]) end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 13 Jan 2008, at 06:22, Harp Oon wrote:> > I also updated the routes.rb file, adding in there: > map.story ''story/show/:permalink'', :controller => ''story'', :action => > ''show'' >Where did you add this line in the routes file? For it to take priority over the route where the parameter is :id (ie the default route, or what you get with map.resources) it needs to be higher up in the file. Fred> Now when I run the server, and type in: > http://localhost:3000/story/show/weblog > > I get the following error: > > NoMethodError in Story#show > > Showing story/show.rhtml where line #2 raised: > > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.name > > Extracted source (around line #2): > > 1: <p> My Story </p> > 2: <h2><%= @story.name %></h2> > 3: <p><%= link_to @story.link, @story.link %></p> > > RAILS_ROOT: /home/hkhan/digg > Application Trace | Framework Trace | Full Trace > > app/views/story/show.rhtml:2:in > `_run_erb_47app47views47story47show46rhtml'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:637:in > `send'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:637:in > `compile_and_render_template'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:365:in > `render_template'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:316:in > `render_file'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:1100:in > `render_for_file'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:836:in > `render_with_no_layout'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/layout.rb:262:in > `render_without_benchmark'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:51:in > `render'' > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:51:in > `render'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:1153:in > `default_render'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:1159:in > `perform_action_without_filters'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/filters.rb:697:in > `call_filters'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/filters.rb:689:in > `perform_action_without_benchmark'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/rescue.rb:199:in > `perform_action_without_caching'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/caching.rb:678:in > `perform_action'' > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract/query_cache.rb:33:in > `cache'' > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/query_cache.rb:8:in > `cache'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/caching.rb:677:in > `perform_action'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:524:in > `send'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:524:in > `process_without_filters'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/filters.rb:685:in > `process_without_session_management_support'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/session_management.rb:123:in > `process'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:388:in > `process'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:171:in > `handle_request'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:115:in > `dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:126:in > `dispatch_cgi'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:9:in > `dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > 112:in > `handle_dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > 78:in > `service'' > /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' > /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' > /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' > /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' > /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' > /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > 62:in > `dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ > webrick.rb:66 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require'' > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > active_support/dependencies.rb:496:in > `require'' > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > active_support/dependencies.rb:342:in > `new_constants_in'' > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > active_support/dependencies.rb:496:in > `require'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb: > 39 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require'' > script/server:3 > > app/views/story/show.rhtml:2:in > `_run_erb_47app47views47story47show46rhtml'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:637:in > `send'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:637:in > `compile_and_render_template'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:365:in > `render_template'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > base.rb:316:in > `render_file'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:1100:in > `render_for_file'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:836:in > `render_with_no_layout'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/layout.rb:262:in > `render_without_benchmark'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:51:in > `render'' > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:51:in > `render'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:1153:in > `default_render'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:1159:in > `perform_action_without_filters'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/filters.rb:697:in > `call_filters'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/filters.rb:689:in > `perform_action_without_benchmark'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/rescue.rb:199:in > `perform_action_without_caching'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/caching.rb:678:in > `perform_action'' > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract/query_cache.rb:33:in > `cache'' > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/query_cache.rb:8:in > `cache'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/caching.rb:677:in > `perform_action'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:524:in > `send'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:524:in > `process_without_filters'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/filters.rb:685:in > `process_without_session_management_support'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/session_management.rb:123:in > `process'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/base.rb:388:in > `process'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:171:in > `handle_request'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:115:in > `dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:126:in > `dispatch_cgi'' > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > action_controller/dispatcher.rb:9:in > `dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > 112:in > `handle_dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > 78:in > `service'' > /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' > /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' > /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' > /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' > /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' > /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' > /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > 62:in > `dispatch'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ > webrick.rb:66 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require'' > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > active_support/dependencies.rb:496:in > `require'' > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > active_support/dependencies.rb:342:in > `new_constants_in'' > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > active_support/dependencies.rb:496:in > `require'' > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb: > 39 > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'' > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require'' > script/server:3 > > Request > > Parameters: > > {"id"=>"weblog"} > > Show session dump > > --- > :csrf_id: d13a9d7dbf67db04912fb3bdfe1dc0bc > flash: !map:ActionController::Flash::FlashHash {} > > > Response > > Headers: > > {"cookie"=>[], > "Cache-Control"=>"no-cache"} > > > But if I change the controller to: > def show > #@story = Story.find_by_permalink(params[:permalink]) > @story = Story.find_by_id(params[:id]) > end > > and then do: > http://localhost:3000/story/show/1 > > Then I get the correct output. > > > Any ideas????? > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This could be if the new field :permalink is not populated in the database yet! find_by_permalink looks into the database, and finds a column of nil records, so controller sends a nil @story into the view. The error is picked up in the view where it evaluates @story.name On Jan 22, 2:37 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 13 Jan 2008, at 06:22, Harp Oon wrote:t > > > > > I also updated the routes.rb file, adding in there: > > map.story ''story/show/:permalink'', :controller => ''story'', :action => > > ''show'' > > Where did you add this line in the routes file? For it to take > priority over the route where the parameter is :id (ie the default > route, or what you get with map.resources) it needs to be higher up in > the file. > > Fred > > > Now when I run the server, and type in: > >http://localhost:3000/story/show/weblog > > > I get the following error: > > > NoMethodError in Story#show > > > Showing story/show.rhtml where line #2 raised: > > > You have a nil object when you didn''t expect it! > > The error occurred while evaluating nil.name > > > Extracted source (around line #2): > > > 1: <p> My Story </p> > > 2: <h2><%= @story.name %></h2> > > 3: <p><%= link_to @story.link, @story.link %></p> > > > RAILS_ROOT: /home/hkhan/digg > > Application Trace | Framework Trace | Full Trace > > > app/views/story/show.rhtml:2:in > > `_run_erb_47app47views47story47show46rhtml'' > > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:637:in > > `send'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:637:in > > `compile_and_render_template'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:365:in > > `render_template'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:316:in > > `render_file'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:1100:in > > `render_for_file'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:836:in > > `render_with_no_layout'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/layout.rb:262:in > > `render_without_benchmark'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:51:in > > `render'' > > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:51:in > > `render'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:1153:in > > `default_render'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:1159:in > > `perform_action_without_filters'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/filters.rb:697:in > > `call_filters'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/filters.rb:689:in > > `perform_action_without_benchmark'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue'' > > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/rescue.rb:199:in > > `perform_action_without_caching'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/caching.rb:678:in > > `perform_action'' > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract/query_cache.rb:33:in > > `cache'' > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/query_cache.rb:8:in > > `cache'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/caching.rb:677:in > > `perform_action'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:524:in > > `send'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:524:in > > `process_without_filters'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/filters.rb:685:in > > `process_without_session_management_support'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/session_management.rb:123:in > > `process'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:388:in > > `process'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:171:in > > `handle_request'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:115:in > > `dispatch'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:126:in > > `dispatch_cgi'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:9:in > > `dispatch'' > > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > > 112:in > > `handle_dispatch'' > > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > > 78:in > > `service'' > > /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' > > /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'' > > /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'' > > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: > > 62:in > > `dispatch'' > > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ > > webrick.rb:66 > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_require'' > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `require'' > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > > active_support/dependencies.rb:496:in > > `require'' > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > > active_support/dependencies.rb:342:in > > `new_constants_in'' > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ > > active_support/dependencies.rb:496:in > > `require'' > > /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb: > > 39 > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_require'' > > /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `require'' > > script/server:3 > > > app/views/story/show.rhtml:2:in > > `_run_erb_47app47views47story47show46rhtml'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:637:in > > `send'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:637:in > > `compile_and_render_template'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:365:in > > `render_template'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/ > > base.rb:316:in > > `render_file'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:1100:in > > `render_for_file'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:836:in > > `render_with_no_layout'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/layout.rb:262:in > > `render_without_benchmark'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:51:in > > `render'' > > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:51:in > > `render'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:1153:in > > `default_render'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:1159:in > > `perform_action_without_filters'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/filters.rb:697:in > > `call_filters'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/filters.rb:689:in > > `perform_action_without_benchmark'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue'' > > /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/benchmarking.rb:68:in > > `perform_action_without_rescue'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/rescue.rb:199:in > > `perform_action_without_caching'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/caching.rb:678:in > > `perform_action'' > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract/query_cache.rb:33:in > > `cache'' > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/query_cache.rb:8:in > > `cache'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/caching.rb:677:in > > `perform_action'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:524:in > > `send'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:524:in > > `process_without_filters'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/filters.rb:685:in > > `process_without_session_management_support'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/session_management.rb:123:in > > `process'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/base.rb:388:in > > `process'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:171:in > > `handle_request'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:115:in > > `dispatch'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:126:in > > `dispatch_cgi'' > > /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ > > action_controller/dispatcher.rb:9:in > > `dispatch'' > > ... > > read more »--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---