Skip to content

Instantly share code, notes, and snippets.

@johndavid400
johndavid400 / gist:1042615
Created June 23, 2011 14:14
no mehtod upcase?
NoMethodError in Stocks#index
Showing /home/jd/isotope/dividend_reporter/app/views/stocks/index.html.erb where line #13 raised:
undefined method `upcase' for nil:NilClass
Extracted source (around line #13):
10:
11: <% @stocks.each do |stock| %>
1 DividendReporter::Application.routes.draw do
2
3 resources :roles
4
5 resources :stocks do
6 member do
7 post :watch
8 end
9 end
10
78 def watch
79 @stock = Stock.find(params[:id])
80 UserStock.create(:user_id => current_user.id, :stock_id => @stock.id)
81 flash[:notice] = "Stock was added to your watch list"
82 redirect_to stocks_path
83 end
ruby-1.9.2-p180 :002 > a1.gallery.images.create(:image => File.open(File.join(Rails.root, "db", "seeds", "images", "a2.jpg")))
NoMethodError: undefined method `images' for nil:NilClass
from /home/jd/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc4/lib/active_support/whiny_nil.rb:48:in `method_missing'
from (irb):2
from /home/jd/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:45:in `start'
from /home/jd/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:8:in `start'
from /home/jd/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.rc4/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ruby-1.9.2-p180 :034 > a = ::Refinery::Article.create :content => "Blah", :title => "Tester"
(0.2ms) SELECT 1 FROM "refinery_articles" WHERE "refinery_articles"."title" = 'Tester' LIMIT 1
SQL (0.8ms) INSERT INTO "refinery_articles" ("author_id", "content", "created_at", "position", "published_at", "title", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["author_id", nil], ["content", "Blah"], ["created_at", Wed, 29 Jun 2011 15:44:03 UTC +00:00], ["position", nil], ["published_at", nil], ["title", "Tester"], ["updated_at", Wed, 29 Jun 2011 15:44:03 UTC +00:00]]
(0.1ms) SELECT 1 FROM "refinery_galleries" WHERE "refinery_galleries"."title" = 'Tester' LIMIT 1
SQL (0.3ms) INSERT INTO "refinery_galleries" ("article_id", "created_at", "title", "updated_at") VALUES (?, ?, ?, ?) [["article_id", 6], ["created_at", Wed, 29 Jun 2011 15:44:03 UTC +00:00], ["title", "Tester"], ["updated_at", Wed, 29 Jun 2011 15:44:03 UTC +00:00]]
(0.2ms) SELECT COUNT(*) FROM "slugs" WHERE "slugs"."sluggable_id" IS NULL AN
rake db:create
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Spec::Rake::SpecTask#task called at /home/jd/isotope/mapto/lib/tasks/rspec.rake:28:in `initialize'
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Spec::Rake::SpecTask#task called at /home/jd/isotope/mapto/lib/tasks/rspec.rake:28:in `initialize'
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
$ rake db:migrate --trace
(in /home/jd/isotope/mapto)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `abstract_class?' for Object:Class
/home/jd/.rvm/gems/ruby-1.8.7-p334@mapto/gems/activerecord-2.3.5/lib/active_record/base.rb:2207:in `class_of_active_record_descendant'
/home/jd/.rvm/gems/ruby-1.8.7-p334@mapto/gems/activerecord-2.3.5/lib/active_record/base.rb:1462:in `base_class'
/home/jd/.rvm/gems/ruby-1.8.7-p334@mapto/gems/activerecord-2.3.5/lib/active_record/base.rb:1138:in `reset_table_name'
Using with factory-girl or machinist
But you’re using Machinist or FactoryGirl right?! To leverage all of the factories/blueprints you’ve written, you can just do stuff like
Given a user exists
And another user exists with role: "admin"
# later
Then a user should exist with name: "Fred"
And that user should be activated # this uses rspec predicate matchers
NoMethodError in Forem::TopicsController#show
undefined method `topics' for nil:NilClass
Rails.root: /home/jd/isotope/a2_fansites
Application Trace | Framework Trace | Full Trace
activesupport (3.1.0.rc5) lib/active_support/whiny_nil.rb:48:in `method_missing'
app/controllers/forem/topics_controller.rb:8:in `show'
actionpack (3.1.0.rc5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title></title>
5 <%= stylesheet_link_tag :all %>
6 <%= javascript_include_tag :jquery, :defaults %>
7 <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" %>
8 <%= csrf_meta_tag %>
9 </head>
10 <body>