"TypeError: no implicit conversion of nil into String" when eager loading results - ruby-on-rails-3

I'm using ruby '2.3.0' and 'rails', '3.2.22.2'.
I need a little help & explanations about a query I've made. Here's my models:
class AssessmentRaw < ActiveRecord::Base
belongs_to :session
has_many :schedulers, :class_name => 'MailingScheduler', :as => :owner, :dependent => :destroy
end
class MailingScheduler < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
end
class Session < ActiveRecord::Base
has_many :assessment_raws, :dependent => :destroy
end
I want to retrieve all the assessment_raws, and eager load the associated sessions and mailing_schedulers.
1. eager load only sessions
ars = AssessmentRaw.includes(:session).where("sessions.start_at >= ?", 1.year.ago).limit(10)
ars.map { |ar| ar.session.id }
=> [2877, 2878, 2879, 2880, 2881, 2882, 2883, 2884, 2902, 2903]
`ars.map { |ar| ar.schedulers.try(:size) }`
MailingScheduler Load (0.6ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 622 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.6ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 725 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.3ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 771 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.3ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 782 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.3ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 881 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.2ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 996 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.3ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 1087 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.3ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 1155 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.2ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 653 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
MailingScheduler Load (0.2ms) SELECT "mailing_schedulers".* FROM "mailing_schedulers" WHERE "mailing_schedulers"."owner_id" = 940 AND "mailing_schedulers"."owner_type" = 'AssessmentRaw'
=> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Of course to get the count of the mailing_schedulers, rails must query (N+1 problem)
2. eager load sessions and mailing_schedulers
ars = AssessmentRaw.includes(:schedulers,:session).where("sessions.start_at >= ?", 1.year.ago).limit(10)
TypeError: no implicit conversion of nil into String
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/arel-3.0.3/lib/arel.rb:40:in `initialize'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/arel-3.0.3/lib/arel.rb:40:in `new'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/arel-3.0.3/lib/arel.rb:40:in `sql'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_helper.rb:47:in `block in sanitize'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_helper.rb:45:in `map'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_helper.rb:45:in `sanitize'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_dependency/join_association.rb:104:in `block in join_to'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_dependency/join_association.rb:74:in `each'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_dependency/join_association.rb:74:in `each_with_index'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/associations/join_dependency/join_association.rb:74:in `join_to'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/query_methods.rb:370:in `block in build_joins'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/query_methods.rb:369:in `each'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/query_methods.rb:369:in `build_joins'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/query_methods.rb:266:in `build_arel'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/query_methods.rb:260:in `arel'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/finder_methods.rb:259:in `construct_limited_ids_condition'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/finder_methods.rb:243:in `apply_join_dependency'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/finder_methods.rb:232:in `construct_relation_for_association_find'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation/finder_methods.rb:211:in `find_with_associations'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation.rb:171:in `exec_queries'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation.rb:160:in `block in to_a'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/explain.rb:41:in `logging_query_plan'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation.rb:159:in `to_a'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/activerecord-3.2.22.2/lib/active_record/relation.rb:498:in `inspect'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/railties-3.2.22.2/lib/rails/commands/console.rb:47:in `start'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/railties-3.2.22.2/lib/rails/commands/console.rb:8:in `start'
from /Users/oim/.rbenv/versions/2.3.0/gemsets/project-gems/gems/railties-3.2.22.2/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):064:0>
ouch. I think I need a LEFT OUTER JOIN here because all assessment_raws doesn't have mailing_schedulers, right?
Any help appreciated.

This issue occurs due to a change made in Ruby 2.3 where Hash now responds to to_proc which confuses the interpolate method. See this bug report for more details: https://github.com/rails/rails/issues/25010. Also note there is a workaround mentioned which resolved the issue for me, but unless you're sure you don't use the new to_proc it could potentially be dangerous.
What worked for me: I added the suggested monkey patch (as shown below) to the top of my config/application.rb
class Hash
undef_method :to_proc if self.method_defined?(:to_proc)
end

Related

Rails: Reducing the amount of ActiveStorage queries

I've got an index page that displays 3 different resources (Ablum, Samplepack and Demo), and 2 of them has attached images. I'm loading them through my controller like so:
# static_controller.rb
#resources = []
#resources.push(Album.all, Demo.all, Samplepack.all)
It results in a lot of SQL queries in order to load them. I was wondering if there was a most efficient way to loads attachments ? If anyone could copy/paste me a link to some readings it'd be awesome !
I was thinking about something with includes or joins but I can't find any reference on the Web.
Have a great day
EDIT: As Sebastian Palma mentioned, with_attached_<attachment> is required (non exhaustive logs for the sake of brevity)
[Album.all, Demo.all, Samplepack.all]
# resulting SQL
# Album n°1
ActiveStorage::Attachment Load (1.8ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 82], ["record_type", "Album"], ["name", "album_artwork"], ["LIMIT", 1]]
ActiveStorage::Blob Load (2.4ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 1227], ["LIMIT", 1]]
# Ablum n°2
ActiveStorage::Attachment Load (0.2ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 83], ["record_type", "Album"], ["name", "album_artwork"], ["LIMIT", 1]]
ActiveStorage::Blob Load (0.1ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 1228], ["LIMIT", 1]]
# Album n°3
ActiveStorage::Attachment Load (0.2ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 84], ["record_type", "Album"], ["name", "album_artwork"], ["LIMIT", 1]]
ActiveStorage::Blob Load (0.2ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 1229], ["LIMIT", 1]]
...
... N+1 town (even N+2 ?)
Using with_attached_<attachment>:
#resources = [
Album.with_attached_album_artwork.all,
Demo.all,
Samplepack.with_attached_album_artwork.all
]
# Albums
ActiveStorage::Attachment Load (0.6ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_type" = $1 AND "active_storage_attachments"."name" = $2 AND "active_storage_attachments"."record_id" IN ($3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) [["record_type", "Album"], ["name", "album_artwork"], ["record_id", 82], ["record_id", 83], ["record_id", 84], ["record_id", 85], ["record_id", 86], ["record_id", 87], ["record_id", 88], ["record_id", 89], ["record_id", 91], ["record_id", 93], ["record_id", 94], ["record_id", 95]]
ActiveStorage::Blob Load (0.4ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) [["id", 1239], ["id", 1242], ["id", 1244], ["id", 1227], ["id", 1228], ["id", 1229], ["id", 1230], ["id", 1231], ["id", 1232], ["id", 1236], ["id", 1237], ["id", 1241]]
# Samplepacks
ActiveStorage::Attachment Load (0.3ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_type" = $1 AND "active_storage_attachments"."name" = $2 AND "active_storage_attachments"."record_id" = $3 [["record_type", "Samplepack"], ["name", "album_artwork"], ["record_id", 56]]
ActiveStorage::Blob Load (0.2ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 [["id", 1243]]
Depending in your case (has_many/has_one) use with_attached_<attachment>:
To avoid N+1 queries, you can include the attached blobs in your query
like so:
Gallery.where(user: Current.user).with_attached_photos
So:
[
Album.all,
Demo.with_attached_images.all,
Samplepack.with_attached_images.all
]
I think there's no need to create an empty array to fill it then.
There's perhaps also a problem since you're using all, check what you really need from each model.

Application error heroku, ruby on rails tutorial

I am following the ruby on rails tutorial(recomended here on stack:) ) Loved it so far but i can't seem to deploy my application via heroku. Can someone give me light on what to do?
2015-07-23T23:46:37.387879+00:00 heroku[web.1]: Process exited with status 1
2015-07-23T23:46:37.390702+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-23T23:46:38.056116+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/?_c9_id=livepreview7&_c9_host=https://ide.c9.io" host=vast-shore-9845.herokuapp.com request_id=9bc94d44-685f-4554-9940-fe01f5f8acfc fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-23T23:47:04.275534+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2015-07-23T23:47:04.275511+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-23T23:47:34.243854+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-23T23:47:34.243873+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2015-07-23T23:47:48.259354+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/?_c9_id=livepreview7&_c9_host=https://ide.c9.io" host=vast-shore-9845.herokuapp.com request_id=80c80609-252a-4603-adc1-ef8fd3803675 fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-23T23:50:42.867239+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-23T23:50:42.867266+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2015-07-23T23:53:02.818263+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-23T23:53:02.818432+00:00 heroku[slug-compiler]: Slug compilation finished
2015-07-23T23:53:02.741040+00:00 heroku[api]: Deploy cb3c9d8 by
2015-07-23T23:53:02.741040+00:00 heroku[api]: Release v6 created by
2015-07-23T23:53:02.845508+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-23T23:53:07.556502+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 10779 -e production`
2015-07-23T23:53:11.732808+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails/helpers.rb:11:in `<top (required)>': uninitialized constant Sass::Script (NameError)
2015-07-23T23:53:11.732845+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `<top (required)>'
2015-07-23T23:53:11.732841+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `require'
2015-07-23T23:53:11.732848+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `<top (required)>'
2015-07-23T23:53:11.732853+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
2015-07-23T23:53:11.732847+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `require'
2015-07-23T23:53:11.732850+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
2015-07-23T23:53:11.732854+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
2015-07-23T23:53:11.732856+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
2015-07-23T23:53:11.732857+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
2015-07-23T23:53:11.732864+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
2015-07-23T23:53:11.732880+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-07-23T23:53:11.732878+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
2015-07-23T23:53:11.732867+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
2015-07-23T23:53:11.732859+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
2015-07-23T23:53:11.732865+00:00 app[web.1]: from /app/config/application.rb:7:in `<top (required)>'
2015-07-23T23:53:11.732881+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-07-23T23:53:11.732882+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-07-23T23:53:11.732884+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
2015-07-23T23:53:11.732885+00:00 app[web.1]: from bin/rails:8:in `require'
2015-07-23T23:53:11.732886+00:00 app[web.1]: from bin/rails:8:in `<main>'
2015-07-23T23:53:12.670912+00:00 heroku[web.1]: Process exited with status 1
2015-07-23T23:53:12.675113+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-23T23:53:26.378922+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-shore-9845.herokuapp.com request_id=fcb97d6f-128b-4d2b-b3e8-c2de87eb7e33 fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-23T23:53:25.583623+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-shore-9845.herokuapp.com request_id=00322a0d-ad99-43c9-8c40-090c0459cfba fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-23T23:59:48.868798+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-23T23:59:48.868814+00:00 heroku[slug-compiler]: Slug compilation finished
2015-07-23T23:59:48.811695+00:00 heroku[api]: Deploy d7257fd by
2015-07-23T23:59:48.811695+00:00 heroku[api]: Release v7 created by
2015-07-23T23:59:48.962017+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-23T23:59:53.564068+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 45661`
2015-07-23T23:59:56.828404+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails/helpers.rb:11:in `<top (required)>': uninitialized constant Sass::Script (NameError)
2015-07-23T23:59:56.828424+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `require'
2015-07-23T23:59:56.828426+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `<top (required)>'
2015-07-23T23:59:56.828428+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `require'
2015-07-23T23:59:56.828429+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `<top (required)>'
2015-07-23T23:59:56.828431+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
2015-07-23T23:59:56.828435+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
2015-07-23T23:59:56.828437+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
2015-07-23T23:59:56.828438+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
2015-07-23T23:59:56.828440+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
2015-07-23T23:59:56.828441+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
2015-07-23T23:59:56.828442+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
2015-07-23T23:59:56.828444+00:00 app[web.1]: from /app/config/application.rb:7:in `<top (required)>'
2015-07-23T23:59:56.828445+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
2015-07-23T23:59:56.828447+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
2015-07-23T23:59:56.828448+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-07-23T23:59:56.828449+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-07-23T23:59:56.828450+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-07-23T23:59:56.828452+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
2015-07-23T23:59:56.828453+00:00 app[web.1]: from bin/rails:8:in `require'
2015-07-23T23:59:56.828457+00:00 app[web.1]: from bin/rails:8:in `<main>'
2015-07-23T23:59:57.609465+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-23T23:59:57.597734+00:00 heroku[web.1]: Process exited with status 1
2015-07-23T23:59:57.610775+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-24T00:00:00.487775+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 28996`
2015-07-24T00:00:03.609964+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails/helpers.rb:11:in `<top (required)>': uninitialized constant Sass::Script (NameError)
2015-07-24T00:00:03.609994+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `require'
2015-07-24T00:00:03.609997+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass/rails.rb:8:in `<top (required)>'
2015-07-24T00:00:03.609998+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `require'
2015-07-24T00:00:03.610000+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/sass-rails-5.0.1/lib/sass-rails.rb:1:in `<top (required)>'
2015-07-24T00:00:03.610001+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
2015-07-24T00:00:03.610003+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
2015-07-24T00:00:03.610004+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
2015-07-24T00:00:03.610009+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
2015-07-24T00:00:03.610010+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
2015-07-24T00:00:03.610012+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
2015-07-24T00:00:03.610013+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
2015-07-24T00:00:03.610014+00:00 app[web.1]: from /app/config/application.rb:7:in `<top (required)>'
2015-07-24T00:00:03.610016+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require'
2015-07-24T00:00:03.610017+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server'
2015-07-24T00:00:03.610019+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-07-24T00:00:03.610020+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-07-24T00:00:03.610021+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-07-24T00:00:03.610023+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
2015-07-24T00:00:03.610024+00:00 app[web.1]: from bin/rails:8:in `require'
2015-07-24T00:00:03.610026+00:00 app[web.1]: from bin/rails:8:in `<main>'
2015-07-24T00:00:04.345273+00:00 heroku[web.1]: Process exited with status 1
2015-07-24T00:00:04.356753+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-24T00:00:09.963238+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-shore-9845.herokuapp.com request_id=822845f6-3908-4248-a575-814ca10d22d2 fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-24T00:00:10.800435+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-shore-9845.herokuapp.com request_id=873c38e3-d55c-4645-8ac5-97422fa125bb fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-24T00:03:43.594872+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-shore-9845.herokuapp.com request_id=16ab9874-71c4-48f4-9ce8-a20958396716 fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-24T00:03:44.334194+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-shore-9845.herokuapp.com request_id=d21a4989-daab-4363-bcfc-a482c9977a41 fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-24T00:06:37.583563+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-shore-9845.herokuapp.com request_id=f06c025a-ee76-4d4e-aa87-e2c9fa4ddf32 fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
2015-07-24T00:06:38.170649+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-shore-9845.herokuapp.com request_id=45c72e79-010e-48f5-8859-ff28a299e0ef fwd="84.81.77.100" dyno= connect= service= status=503 bytes=
WARNING: Toolbelt v3.40.6 update available.
The issue is actually with the gem version 5.0.1 so just run:
bundle update sass-rails
which ultimately updates you saas-rails gem to the latest one. Or you can enter the version 5.0.2+ in your Gemfile like
gem 'sass-rails', '5.0.3'

thinking sphinx search has_many not working no error

model
class Person < ActiveRecord::Base
attr_accessible :alignment, :description, :first_name, :last_name
has_many :roles #table roles with active as one of the field with value equal t or f (boolean)
end
class Role < ActiveRecord::Base
attr_accessible :active, :organization_id, :person_id, :position_id
belongs_to :person
belongs_to :organization
belongs_to :position
end
person_index.rb
ThinkingSphinx::Index.define :person, :with => :active_record do
#Fields
indexes last_name, :sortable => true
indexes first_name, :sortable => true
indexes alignment
#indexes role(:active), :as => :active
indexes role.active, :as => :active
#Attributes
has created_at, updated_at
has professions(:id), :as => :profession_ids
has positions(:id), :as => :position_id
has organizations(:id), :as => :organization_id
end
people_controller
filters = {}
filters[:profession_ids] = params[:profession_ids] if params[:profession_ids].present?
filters[:organization_id] = params[:organization_id] if params[:organization_id].present?
filters[:position_id] = params[:position_id] if params[:position_id].present?
filters[:active_ids] = role if params[:active].present? #added
#people = Person.search " #{params[:lastname]} #{params[:firstname]} #{params[:alignmemt]}",
:with => filters,
:star => true,
:condition => {:alignment => params[:alignment], :active => params[:active]},
:order => 'last_name ASC, first_name ASC',
:page => params[:page],
:per_page => 20
When i search active and/or alignment it is not filtering result and doesn't give me error. these are both string field, alignment is in the people table and active is in another table (roles)
Why? What am i missing?
update
Tried the recommended solution for active on this question and same result...
person_index.rb
ThinkingSphinx::Index.define :person, :with => :active_record do
#Fields
indexes last_name, :sortable => true
indexes first_name, :sortable => true
indexes alignment
#Attributes
has created_at, updated_at
has professions(:id), :as => :profession_ids
has positions(:id), :as => :position_id
has organizations(:id), :as => :organization_id
has roles.active, :as => :active_ids
end
people_controller
def index
#role = Role.find_by_active(params[:active]) #ADDED
filters = {}
filters[:profession_ids] = params[:profession_ids] if params[:profession_ids].present?
filters[:organization_id] = params[:organization_id] if params[:organization_id].present?
filters[:position_id] = params[:position_id] if params[:position_id].present?
#people = Person.search " #{params[:lastname]} #{params[:firstname]} #{params[:alignmemt]}",
:with => filters,
:star => true,
:condition => {:alignment => params[:alignment], :active_ids => #role}, #CHANGED
:order => 'last_name ASC, first_name ASC',
:page => params[:page],
:per_page => 20
but still have same result... WHY?
controller updated after Pat answer
def index
if params[:active].present?
role = Array.new
rolepid = Array.new
role = Role.find_all_by_active(params[:active])
role.each do |num|
puts num.person_id
rolepid << num.person_id #get all the person id whith the params[:active]
end
end
filters = {}
filters[:profession_ids] = params[:profession_ids] if params[:profession_ids].present?
filters[:organization_id] = params[:organization_id] if params[:organization_id].present?
filters[:position_id] = params[:position_id] if params[:position_id].present?
filters[:active_ids] = rolepid if params[:active].present?
#people = Person.search " #{params[:lastname]} #{params[:firstname]} #{params[:alignent]}",
#:classes => [Person, Role],
:with => filters,
:star => true,
:condition => {:alignment => params[:alignment]},
:order => 'last_name ASC, first_name ASC',
:page => params[:page],
:per_page => 20
But now it is looking for active in people table when it should look in roles table. So i added #:classes => [Person, Role], but no luck....
Role Load (0.7ms) SELECT "roles".* FROM "roles" WHERE "roles"."active" = 'f'
Sphinx Query (0.7ms) SELECT * FROM `person_core` WHERE `active_ids` IN (304, 34, 306, 308, 334, 295, 344, 348, 352, 354, 365, 367, 308, 429, 468, 9, 544, 590, 609, 110, 1643, 1652, 1653, 1655, 1669, 628, 1687, 1691, 1709) AND `sphinx_deleted` = 0 ORDER BY `last_name` ASC, first_name ASC LIMIT 0, 20
Sphinx Found 0 results
So i change in the controller
filters[:active_ids] = rolepid if params[:active].present?
to
filters[:id] = rolepid if params[:active].present?
Since rolepid is an array of integer with the person ids.
But Sphinx is just looking for 4 ids that are not in rolepid... I am confused :|
Parameters: {"utf8"=>"✓", "firstname"=>"", "lastname"=>"", "alignment"=>"", "organization_id"=>"", "position_id"=>"", "active"=>"f", "commit"=>"Search"}
Role Load (0.8ms) SELECT "roles".* FROM "roles" WHERE "roles"."active" = 'f'
Sphinx Query (0.6ms) SELECT * FROM `person_core` WHERE `id` IN (304, 34, 306, 308, 334, 295, 344, 348, 352, 354, 365, 367, 308, 429, 468, 9, 544, 590, 609, 110, 1643, 1652, 1653, 1655, 1669, 628, 1687, 1691, 1709) AND `sphinx_deleted` = 0 ORDER BY `last_name` ASC, first_name ASC LIMIT 0, 20
Sphinx Found 4 results
Person Load (0.4ms) SELECT "people".* FROM "people" WHERE "people"."id" IN (84, 1, 61, 50)
Why is it not returning the 29 records from rolepid array ?
filtering for alignment IS working. thanks for catching the misspelled word.
If you're using active_ids as an attribute (which, if it's integers, is certainly appropriate), then it should be a filter in the :with option, not in the :conditions option.
I'm not sure if this is related, but it's worth noting you've misspelled alignment in the query string (you've got alignmemt instead).

Heroku Application Error Occur

Heroku Application error
I don't understand why this will be happen.Can anyone tell me why this will be happening...?
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
Logs
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/config.ru:in `new'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/config.ru:in `<main>'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
2014-01-15T09:12:41.883290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
2014-01-15T09:12:41.882761+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
2014-01-15T09:12:41.883859+00:00 app[web.1]: from bin/rails:4:in `require'
2014-01-15T09:12:41.883457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
2014-01-15T09:12:41.883859+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
2014-01-15T09:12:41.883859+00:00 app[web.1]: from bin/rails:4:in `<main>'
2014-01-15T09:12:41.913025+00:00 app[web.1]: => Booting WEBrick
2014-01-15T09:12:41.913025+00:00 app[web.1]: => Rails 4.0.2 application starting in production on http://0.0.0.0:49194
2014-01-15T09:12:41.913025+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-01-15T09:12:41.913025+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-01-15T09:12:41.913025+00:00 app[web.1]: Exiting
2014-01-15T09:12:43.365057+00:00 heroku[web.1]: Process exited with status 1
2014-01-15T09:12:43.388570+00:00 heroku[web.1]: State changed from starting to crashed
2014-01-15T09:34:57.545417+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=scitech.herokuapp.com fwd="39.36.135.145" dyno= connect= service= status=503 bytes=
2014-01-15T09:34:58.737978+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=scitech.herokuapp.com fwd="39.36.135.145" dyno= connect= service= status=503 bytes=
2014-01-15T09:39:33.012548+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
2014-01-15T09:39:37.499410+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
2014-01-15T09:39:37.937049+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
2014-01-15T09:39:31.872794+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
2014-01-15T09:40:42.463904+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
2014-01-15T09:40:43.143297+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
2014-01-15T09:43:54.807645+00:00 heroku[web.1]: State changed from crashed to starting
2014-01-15T09:43:57.879492+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 4381 -e $RAILS_ENV`
2014-01-15T09:44:00.873725+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require': /app/app/models/banners.rb:2: syntax error, unexpected tIDENTIFIER, expecting '}' (SyntaxError)
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
2014-01-15T09:44:00.873725+00:00 app[web.1]: validates :title, presence: true, length: {minimum: 5 maximum: 25}
2014-01-15T09:44:00.873725+00:00 app[web.1]: ^
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:330:in `require_or_load'
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:289:in `depend_on'
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:207:in `require_dependency'
2014-01-15T09:44:00.873725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:464:in `each'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:464:in `block in eager_load!'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:462:in `each'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:462:in `eager_load!'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:347:in `eager_load!'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:56:in `each'
2014-01-15T09:44:00.874065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
2014-01-15T09:44:00.874393+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/config.ru:3:in `block in <main>'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/config.ru:in `new'
2014-01-15T09:44:00.875246+00:00 app[web.1]: from /app/config.ru:in `<main>'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
2014-01-15T09:44:00.875456+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
2014-01-15T09:44:00.875890+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
2014-01-15T09:44:00.875890+00:00 app[web.1]: from bin/rails:4:in `<main>'
2014-01-15T09:44:00.898780+00:00 app[web.1]: => Booting WEBrick
2014-01-15T09:44:00.898780+00:00 app[web.1]: => Rails 4.0.2 application starting in production on http://0.0.0.0:4381
2014-01-15T09:44:00.898780+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-01-15T09:44:00.898780+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-01-15T09:44:00.898780+00:00 app[web.1]: Exiting
2014-01-15T09:44:00.875890+00:00 app[web.1]: from bin/rails:4:in `require'
2014-01-15T09:44:02.058347+00:00 heroku[web.1]: Process exited with status 1
2014-01-15T09:44:02.077676+00:00 heroku[web.1]: State changed from starting to crashed
2014-01-15T09:44:13.799826+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=scitech.herokuapp.com fwd="39.42.60.156" dyno= connect= service= status=503 bytes=
You have a syntax error in the banners.rb file. Line validates :title, presence: true, length: {minimum: 5 maximum: 25} should be
validates :title, presence: true, length: {minimum: 5, maximum: 25}

NoMethodError: undefined method `Amount' for nil:NilClass

:031:0> #revenue = Revenue.where(:Year=>1983)
←[1m←[36mRevenue Load (1.0ms)←[0m ←[1mSELECT "revenues".* FROM "revenues" WHERE "revenues"."Year" = 1983←[0m
=> [#<Revenue id: 9, Year: 1983, Amount: 4.0, Q1: 1.0, Q2: 1.0, Q3: 1.0, Q4: 1.0
, created_at: "2013-06-11 16:41:16", updated_at: "2013-06-11 16:41:16", estate_i
d: 1>]
irb(main):032:0> #revenues.Amount
NoMethodError: undefined method `Amount' for nil:NilClass
from (irb):32
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/commands/console.rb:47:in `start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/commands/console.rb:8:in `start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):033:0>
Because your revenue object is in #revenue and you are trying #revenues.Amount
so try it #revenue.amount