SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply Rails 2 ~ page 310 _story.html.erb partial

    I get the following errors when the app/views/stories/_story.html partial loads.
    Any help would be appreciated!

    NoMethodError in Stories#index

    Showing stories/_story.html.erb where line #2 raised:

    undefined method `name' for #<Array:0x591fa78>

    Extracted source (around line #2):

    1: <% div_for(story) do %>
    2: <h3><%= link_to story.name, story %></h3>
    3: <p>
    4: Submitted by: <%= story.user.login %>
    5: Score: <%= story.votes_count %>

    Trace of template inclusion: /stories/index.html.erb

    RAILS_ROOT: C:/InstantRails/rails_apps/shovell
    Application Trace | Framework Trace | Full Trace

    app/views/stories/_story.html.erb:2:in `_run_erb_47app47views47stories47_story46html46erb'
    app/views/stories/_story.html.erb:1:in `_run_erb_47app47views47stories47_story46html46erb'
    app/views/stories/index.html.erb:4:in `_run_erb_47app47views47stories47index46html46erb'

    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/capture_helper.rb:142:in `call'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/capture_helper.rb:142:in `capture_erb_with_buffer'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/capture_helper.rb:44:in `capture'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/record_tag_helper.rb:53:in `content_tag_for'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/record_tag_helper.rb:16:in `div_for'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:331:in `render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/partials.rb:117:in `render_partial'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:26:in `benchmark'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:307:in `realtime'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:26:in `benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/partials.rb:116:in `render_partial'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:352:in `render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:836:in `render_with_no_layout'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:262:in `render_without_benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1153:in `default_render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1159:in `perform_action_without_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:76:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:74:in `synchronize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:74:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:159:in `process_client'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:158:in `each'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:158:in `process_client'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `initialize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `new'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in `initialize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in `new'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:282:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:281:in `each'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:281:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:128:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/command.rb:212:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:281
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    script/server:3

    app/views/stories/_story.html.erb:2:in `_run_erb_47app47views47stories47_story46html46erb'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/capture_helper.rb:142:in `call'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/capture_helper.rb:142:in `capture_erb_with_buffer'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/capture_helper.rb:44:in `capture'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/record_tag_helper.rb:53:in `content_tag_for'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/record_tag_helper.rb:16:in `div_for'
    app/views/stories/_story.html.erb:1:in `_run_erb_47app47views47stories47_story46html46erb'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:331:in `render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/partials.rb:117:in `render_partial'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:26:in `benchmark'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:307:in `realtime'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:26:in `benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/partials.rb:116:in `render_partial'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:352:in `render'
    app/views/stories/index.html.erb:4:in `_run_erb_47app47views47stories47index46html46erb'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `send'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:637:in `compile_and_render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:365:in `render_template'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/base.rb:316:in `render_file'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1100:in `render_for_file'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:836:in `render_with_no_layout'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/layout.rb:262:in `render_without_benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:51:in `render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1153:in `default_render'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1159:in `perform_action_without_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:76:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:74:in `synchronize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/rails.rb:74:in `process'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:159:in `process_client'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:158:in `each'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:158:in `process_client'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `initialize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `new'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:285:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in `initialize'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in `new'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel.rb:268:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:282:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:281:in `each'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/configurator.rb:281:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:128:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/mongrel/command.rb:212:in `run'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/mongrel_rails:281
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:489:in `load'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb:64
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
    C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    script/server:3

    Request

    Parameters:

    None

    Show session dump

    ---
    :csrf_id: e2fe13c4705c8237524b50450dd12777
    :user_id: 1
    :return_to:
    flash: !map:ActionController::Flash::FlashHash {}


    Response

    Headers:

    {"cookie"=>[],
    "Cache-Control"=>"no-cache"}

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,029
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    Does your app\controllers\stories_controller.rb file looks like this?
    Code Ruby:
    class StoriesController < ApplicationController
      before_filter :login_required, :only => [ :new, :create ]
      def index
        @stories = Story.find :all,
            :order => 'id DESC',
            :conditions => 'votes_count >= 5'
      end
    .....

    If you do
    Code:
    ..shovell>ruby script/console
    ......
    >>Story.find(:all)
    what do you get?

  3. #3
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I made a correction to app\controllers\stories_controller.rb, but now I get this error:


    NoMethodError in Stories#index

    Showing stories/_story.html.erb where line #4 raised:

    You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.login

    Extracted source (around line #4):

    1: <% div_for(story) do %>
    2: <h3><%= link_to story.name, story %></h3>
    3: <p>
    4: Submitted by: <%= story.user.login %>
    5: Score: <%= story.votes_count %>
    6: </p>
    7: <% end %>

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,029
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    And, if you do
    Code:
    ..shovell>ruby script/console
    ......
    >>Story.find(:all)
    what do you get?

  5. #5
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [#<Story id: 2, name: "SitePoint Forums", link: "sitepointforums.c
    om/forums", created_at: "2008-08-17 10:13:50", updated_at: "2008-08-26 23:18:51"
    , user_id: nil, votes_count: 3>,
    #<Story id: 3, name: "test", link: "
    google.com", created_at: "2008-08-17 11:10:57", updated_at: "2008-08-26 23:18:51
    ", user_id: nil, votes_count: 7>,
    #<Story id: 4, name: "test", link: "
    .google.com", created_at: "2008-08-17 11:12:10", updated_at: "2008-08-26 23:18:5
    1", user_id: nil, votes_count: 44>,
    #<Story id: 5, name: "test again", link: "ht
    tp://google.com", created_at: "2008-08-17 11:12:34", updated_at: "2008-08-26
    23:18:51", user_id: nil, votes_count: 61>,
    #<Story id: 6, name: "test again", l
    ink: "google.com", created_at: "2008-08-17 11:13:02", updated_at: "20
    08-08-26 23:18:51", user_id: nil, votes_count: 19>,
    #<Story id: 7, name: "rob",
    link: "sffdsafs", created_at: "2008-08-17 12:00:28", updated_at: "2008-08-26 23:
    18:51", user_id: nil, votes_count: 1>,
    #<Story id: 8, name: "sadadsa", link: "as
    dsadsad", created_at: "2008-08-17 16:13:39", updated_at: "2008-08-26 23:18:52",
    user_id: nil, votes_count: 0>,
    #<Story id: 9, name: "baby bear", link: "w
    ww.google.com", created_at: "2008-08-17 16:14:41", updated_at: "2008-08-26 23:18
    :52", user_id: nil, votes_count: 21>,
    #<Story id: 10, name: "baby bear", link: "
    ", created_at: "2008-08-17 16:14:50", updated_at: "2008-08-26 23:18:52", user_id
    : nil, votes_count: 8>,
    #<Story id: 11, name: "baby bear", link: "asdasdasd", cr
    eated_at: "2008-08-17 16:18:57", updated_at: "2008-08-26 23:18:52", user_id: nil
    , votes_count: 13>,
    #<Story id: 12, name: "zsfdsad", link: "asdsadsad", created_
    at: "2008-08-17 16:26:15", updated_at: "2008-08-26 23:18:52", user_id: nil, vote
    s_count: 0>,
    #<Story id: 13, name: "zsfdsad", link: "asdsadsad", created_at: "20
    08-08-17 16:26:40", updated_at: "2008-08-26 23:18:52", user_id: nil, votes_count
    : 24>,
    #<Story id: 14, name: "zsfdsad", link: "asdsadsad", created_at: "2008-08-
    17 16:29:21", updated_at: "2008-08-26 23:18:52", user_id: nil, votes_count: 0>,
    #<Story id: 15, name: "dszfdsafs", link: "sdfdsf", created_at: "2008-08-17 16:34
    :27", updated_at: "2008-08-26 23:18:52", user_id: nil, votes_count: 0>,
    #<Story
    id: 16, name: "zxs", link: "dsadfsf", created_at: "2008-08-17 17:01:53", updated
    _at: "2008-08-26 23:18:52", user_id: nil, votes_count: 1>,
    #<Story id: 17, name:
    "xzcxzcxz", link: "zxczczx", created_at: "2008-08-21 12:41:17", updated_at: "20
    08-08-26 23:18:53", user_id: nil, votes_count: 5>,
    #<Story id: 18, name: "rob",
    link: "duke.edu", created_at: "2008-08-26 22:39:54", updated_at: "200
    8-08-26 23:18:53", user_id: nil, votes_count: 0>,
    #<Story id: 19, name: "sadfdds
    ada", link: "asdasdsad", created_at: "2008-08-26 22:55:25", updated_at: "2008-08
    -26 23:18:53", user_id: 1, votes_count: 0>,
    #<Story id: 20, name: "dsfdsf", link
    : "dsfdsf", created_at: "2008-08-26 23:00:13", updated_at: "2008-08-26 23:18:53"
    , user_id: 1, votes_count: 0>,
    #<Story id: 21, name: "dsfdsfdsfs", link: "sdfdsf
    ds", created_at: "2008-08-26 23:00:48", updated_at: "2008-08-26 23:18:53", user_
    id: 1, votes_count: 0>,
    #<Story id: 22, name: "new story", link: "goo
    gle.com", created_at: "2008-08-26 23:01:49", updated_at: "2008-08-26 23:18:53",
    user_id: 1, votes_count: 0>,
    #<Story id: 23, name: "google", link: "g
    oogle.com", created_at: "2008-08-27 10:48:33", updated_at: "2008-08-27 10:48:33"
    , user_id: 1, votes_count: 0>,
    #<Story id: 24, name: "google", link: "
    .google.com", created_at: "2008-08-27 11:08:53", updated_at: "2008-08-27 11:08:5
    3", user_id: 1, votes_count: 0>,
    #<Story id: 25, name: "ASASDASD", link: ":/
    /google.com", created_at: "2008-08-28 17:08:54", updated_at: "2008-08-28 17:
    08:54", user_id: 1, votes_count: 0>,
    #<Story id: 26, name: "asdasdasdasdd", link
    : "google.com", created_at: "2008-08-29 07:16:13", updated_at: "2008-
    08-29 07:16:13", user_id: 1, votes_count: 0>]

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,029
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    I think the problem might be with the rows where
    user_id: nil (in your case 1-18)

    I don't remember where it is in the book, but I remember seeing mention of giving the earlier stories a user_id value.

    I did
    Code Ruby:
    shovell>ruby script/server
    ......
    >>s = Story.find(1)
    ....
    >>s.user_id = 1
    ....
    >>s.save
    ....
    >>s = Story.find(2)
    .....
    >>s.user_id = 1
    .....
    >>s.save
    etc. etc. until they all had user_id values.

  7. #7
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're doing it for 18 stories it might be quicker to do something like this from script/console:

    Code:
    Story.find_by_user_id(nil).each do |s|
      s.user_id = 1
      s.save
    end

  8. #8
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having a similar problem on page 283.

    If I have this code in:

    <p class="submitted_by">
    Submitted by:
    <span><&#37;= @story.user.login %></span>
    </p>

    I get this error:

    You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.login

    14:
    15: <p class="submitted_by">
    16: Submitted by:
    17: <span><%= @story.user.login %></span>
    18: </p>
    19:
    20: <p>
    But if I use the console as Mittineague suggested, it works fine. Of course, that's annoying.

    There's a breakout box called "Data Integrity in Development," that follows, but doesn't go into great detail about how to fix this dynamically. Any ideas how I can fix this? I won't want to go in and assign the user_id every time I want it to work.

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,029
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    You shouldn't need to go into the console and add user_id all the time, only for those entered before the code changes.
    As the breakout box mentions you could either
    1.
    Manually add the missing values to your objects from the Rails console, remembering to use the save method so that the value is stored permanently.
    as shown in a previous post (either my #6 or MrCarrot's #7 example), or
    2.
    Delete all data in your database (via the Rails console), and begin to add your data from scratch via the application.
    If you want to wipe the database, IMHO the easiest way is to
    Code:
    shovell>rake db:reset
    Then any new stories you enter will be using the new changed code and should have the user_id value.

  10. #10
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mittineague,

    Thanks for the rake db:reset command. That's exactly what I needed. A big help (that probably should have been included in the book in that sidebar).


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •