I am trying to setup devise confirmable and testing with mailcatcher. When I try to signup I get end of file reached error with and it points to the create action of the registrations controller. I am using cloud9. I start mailcatcher with mailcatcher --http-port 8081 --ip $IP -f. I start my server with rails server -b $IP -p $PORT. My development.rb file:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = "cloud9-url"
config.action_mailer.default_url_options = { host: host }
config.action_mailer.smtp_settings = { :address => host, :port => 8081 }
I also have the line config.mailer_sender = 'noreply#example.com' in my devise.rb file.
Here's the server log:
Completed 500 Internal Server Error in 30854ms
EOFError (end of file reached):
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/openssl/buffering.rb:182:in `sysread_nonblock'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/openssl/buffering.rb:182:in `read_nonblock'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/smtp.rb:945:in `recv_response'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/smtp.rb:555:in `block in do_start'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/smtp.rb:955:in `critical'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/smtp.rb:555:in `do_start'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/smtp.rb:520:in `start'
mail (2.6.3) lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
mail (2.6.3) lib/mail/message.rb:2141:in `do_delivery'
mail (2.6.3) lib/mail/message.rb:236:in `block in deliver'
actionmailer (4.1.7) lib/action_mailer/base.rb:527:in `block in deliver_mail'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.7) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in `instrument'
actionmailer (4.1.7) lib/action_mailer/base.rb:525:in `deliver_mail'
mail (2.6.3) lib/mail/message.rb:236:in `deliver'
devise (3.5.2) lib/devise/models/authenticatable.rb:172:in `send_devise_notification'
devise (3.5.2) lib/devise/models/confirmable.rb:116:in `send_confirmation_instructions'
devise (3.5.2) lib/devise/models/confirmable.rb:172:in `send_on_create_confirmation_instructions'
activesupport (4.1.7) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.7) lib/active_support/callbacks.rb:221:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:221:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.7) lib/active_record/callbacks.rb:306:in `_create_record'
activerecord (4.1.7) lib/active_record/timestamp.rb:57:in `_create_record'
activerecord (4.1.7) lib/active_record/persistence.rb:483:in `create_or_update'
activerecord (4.1.7) lib/active_record/callbacks.rb:302:in `block in create_or_update'
activesupport (4.1.7) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.7) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.1.7) lib/active_record/persistence.rb:103:in `save'
activerecord (4.1.7) lib/active_record/validations.rb:51:in `save'
activerecord (4.1.7) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (4.1.7) lib/active_record/transactions.rb:268:in `block (2 levels) in save'
activerecord (4.1.7) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
activerecord (4.1.7) lib/active_record/transactions.rb:208:in `transaction'
activerecord (4.1.7) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
activerecord (4.1.7) lib/active_record/transactions.rb:268:in `block in save'
activerecord (4.1.7) lib/active_record/transactions.rb:283:in `rollback_active_record_state!'
activerecord (4.1.7) lib/active_record/transactions.rb:267:in `save'
devise (3.5.2) app/controllers/devise/registrations_controller.rb:17:in `create'
actionpack (4.1.7) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.7) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.7) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.7) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.7) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.7) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.7) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.7) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.7) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.7) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.7) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.7) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.7) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.7) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.7) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.7) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.7) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.7) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.7) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.7) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:82:in `call'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.7) lib/action_dispatch/routing/mapper.rb:45:in `call'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.7) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.7) lib/action_dispatch/routing/route_set.rb:678:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.6.7.152) lib/new_relic/rack/error_collector.rb:43:in `call'
newrelic_rpm (3.6.7.152) lib/new_relic/rack/agent_hooks.rb:22:in `call'
newrelic_rpm (3.6.7.152) lib/new_relic/rack/browser_monitoring.rb:16:in `call'
newrelic_rpm (3.6.7.152) lib/new_relic/rack/developer_mode.rb:28:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.5) lib/rack/etag.rb:23:in `call'
rack (1.5.5) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.5) lib/rack/head.rb:11:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.5) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.7) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.7) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.7) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.7) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.7) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
railties (4.1.7) lib/rails/engine.rb:514:in `call'
railties (4.1.7) lib/rails/application.rb:144:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
rack (1.5.5) lib/rack/content_length.rb:14:in `call'
rack (1.5.5) lib/rack/handler/webrick.rb:60:in `service'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Rendered /usr/local/rvm/gems/ruby-2.2.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.8ms)
Rendered /usr/local/rvm/gems/ruby-2.2.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.7ms)
Rendered /usr/local/rvm/gems/ruby-2.2.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms)
Rendered /usr/local/rvm/gems/ruby-2.2.2/gems/actionpack-4.1.7/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (29.7ms)
Things seem to work ok when I don't use mailcatcher, meaning after I make these changes to the development.rb file:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :test
host = 'cloud9-url'
config.action_mailer.default_url_options = { host: host }
I then run the server and signup and I no longer get any errors.
Edit: If cloud9 is https would this mean I need to change anything in my development.rb file?
Related
I'm using monologue engine to creata a blog. I follow the readme file at https://github.com/jipiboily/monologue to config my app and database.
When i try to create a new article using monologue interface i get this error: undefined method 'year' for nil:NilClass.
Someone does know how to fix it?
Complete log file:
NoMethodError (undefined method `year' for nil:NilClass):
activesupport (4.1.1) lib/active_support/values/time_zone.rb:290:in `parse'
activesupport (4.1.1) lib/active_support/core_ext/string/zones.rb:9:in `in_time_zone'
activerecord (4.1.1) lib/active_record/attribute_methods/time_zone_conversion.rb:37:in `published_at='
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:45:in `public_send'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:26:in `each'
activerecord (4.1.1) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
activerecord (4.1.1) lib/active_record/core.rb:452:in `init_attributes'
activerecord (4.1.1) lib/active_record/core.rb:198:in `initialize'
activerecord (4.1.1) lib/active_record/inheritance.rb:30:in `new'
activerecord (4.1.1) lib/active_record/inheritance.rb:30:in `new'
monologue (0.4.1) app/controllers/monologue/admin/posts_controller.rb:24:in `create'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/railtie.rb:194:in `public_send'
railties (4.1.1) lib/rails/railtie.rb:194:in `method_missing'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
rack (1.5.4) lib/rack/etag.rb:23:in `call'
rack (1.5.4) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.4) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.4) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.4) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.4) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.4) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.4) lib/rack/lock.rb:17:in `call'
rack (1.5.4) lib/rack/content_length.rb:14:in `call'
rack (1.5.4) lib/rack/handler/webrick.rb:60:in `service'
/usr/local/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
I resolved using ruby 2.1.2.
Thanks to all!
It's actually a bug with rails, the fix is to update Rails as you can see in this commit
https://github.com/rails/rails/commit/e88da370f190cabd1e9750c5b3531735950ab415
I have a rails app that displays the games in an NFL week. So, if the user navigates to: url.com/week/1/ it will display all of the games.
The format is: /week/:id
The controller looks like this:
def show
#week = Week.find(params[:id])
#user = User.first #place holder until current_user is implemented
#games = #week.games
end
When I go to check the page I get:
ActiveRecord::RecordNotFound in WeekController#show
Couldn't find Week with 'id'=
Extracted source (around line #154):
152
153
154
155
156
157
record = s.execute([id], self, connection).first
unless record
raise RecordNotFound, "Couldn't find #{name} with '# {primary_key}'=#{id}"
end
record
rescue RangeError
The id is blank, though I don't understand why, because it's in the parameters:
Request
Parameters:
{"id"=>"4"}
I can verify using the rails console that this record/week should exist, but rails can't find it for some reason... this was working fine and all of a sudden stopped working when I added some validations to another model, but I don't see how they can be related. This is a really simple query.
Any thoughts?
edit: Trace included below:
app/models/pick.rb:31:in `pick_within_range'
app/controllers/week_controller.rb:16:in `block in show'
app/controllers/week_controller.rb:11:in `show'
activerecord (4.2.0) lib/active_record/core.rb:154:in `find'
activesupport (4.2.0) lib/active_support/callbacks.rb:427:in `block in make_lambda'
activesupport (4.2.0) lib/active_support/callbacks.rb:189:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:189:in `block in simple'
activesupport (4.2.0) lib/active_support/callbacks.rb:190:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:190:in `block in simple'
activesupport (4.2.0) lib/active_support/callbacks.rb:190:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:190:in `block in simple'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_validate_callbacks'
activemodel (4.2.0) lib/active_model/validations.rb:395:in `run_validations!'
activemodel (4.2.0) lib/active_model/validations/callbacks.rb:113:in `block in run_validations!'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_validation_callbacks'
activemodel (4.2.0) lib/active_model/validations/callbacks.rb:113:in `run_validations!'
activemodel (4.2.0) lib/active_model/validations.rb:334:in `valid?'
activerecord (4.2.0) lib/active_record/validations.rb:58:in `valid?'
activerecord (4.2.0) lib/active_record/validations.rb:83:in `perform_validations'
activerecord (4.2.0) lib/active_record/validations.rb:37:in `save'
activerecord (4.2.0) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (4.2.0) lib/active_record/transactions.rb:286:in `block (2 levels) in save'
activerecord (4.2.0) lib/active_record/transactions.rb:347:in `block in with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:220:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/transactions.rb:286:in `block in save'
activerecord (4.2.0) lib/active_record/transactions.rb:301:in `rollback_active_record_state!'
activerecord (4.2.0) lib/active_record/transactions.rb:285:in `save'
activerecord (4.2.0) lib/active_record/relation/delegation.rb:46:in `each'
activerecord (4.2.0) lib/active_record/relation/delegation.rb:46:in `each'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
rack (1.6.1) lib/rack/etag.rb:24:in `call'
rack (1.6.1) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.1) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
rack (1.6.1) lib/rack/content_length.rb:15:in `call'
rack (1.6.1) lib/rack/handler/webrick.rb:89:in `service'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
So I am using the latest active_model_serializer and I am trying to use them to send an array on Medium.
I use this to make a query for the Medium: Medium.includes([{comments: :user}, :user]).where(user_id: user_ids)
So the Medium belong to a user, medium has many comments and every comment has a user (owner).
Now here are the corresponding serializers:
Medium:
class MediumSerializer < ActiveModel::Serializer
attributes :id,
:text,
:image_video_file_name,
:image_video_croppable_url,
:image_video_thumb_url,
:image_video_big_url
belongs_to :user
has_many :comments
end
Comment:
class CommentSerializer < ActiveModel::Serializer
attributes :id,
:text,
:user_id,
:medium_id
belongs_to :user
end
User:
class UserSerializer < ActiveModel::Serializer
include Avatar
attributes :id,
:name,
:email,
:role,
:avatar
def avatar
Medium.find(self.current_avatar)[0]
end
#has_one :avatar, serializer: AvatarSerializer
has_many :media, :comments
end
And also I have these functions in my Medium:
def image_video_croppable_url
image_video.url(:croppable)
end
def image_video_thumb_url
image_video.url(:thumb)
end
def image_video_big_url
image_video.url(:big)
end
I use Paperclip gem and I needed these functions to get access to sizes of different medium images. Maybe there is a better way for it also.
So now when I do the query, I use this line to pass the info to browser and let the serializer make it JSON nicely:
respond_with media, each_serializer: MediumSerializer
But it gives me this error:
NoMethodError - undefined method `image_video_file_name' for #<Comment:0x007f5a082a4310>:
activemodel (4.2.0) lib/active_model/attribute_methods.rb:433:in `method_missing'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:37:in `block (2 levels) in attributes'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:200:in `block in attributes'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:198:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:198:in `each_with_object'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:198:in `attributes'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:22:in `block (3 levels) in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter.rb:53:in `cache_check'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:21:in `block (2 levels) in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:20:in `map'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:20:in `block in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:224:in `call'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:224:in `block in each_association'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:208:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer.rb:208:in `each_association'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:17:in `serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:9:in `block in serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/array_serializer.rb:5:in `each'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:9:in `map'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter/json.rb:9:in `serializable_hash'
active_model_serializers (0.10.0.rc1) lib/active_model/serializer/adapter.rb:23:in `as_json'
activesupport (4.2.0) lib/active_support/json/encoding.rb:34:in `encode'
activesupport (4.2.0) lib/active_support/json/encoding.rb:21:in `encode'
activesupport (4.2.0) lib/active_support/core_ext/object/json.rb:37:in `to_json_with_active_support_encoder'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:116:in `block in <module:Renderers>'
active_model_serializers (0.10.0.rc1) lib/action_controller/serialization.rb:49:in `block (2 levels) in <module:Serialization>'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:45:in `block in _render_to_body_with_renderer'
/home/kaspar/.rbenv/versions/2.2.0/lib/ruby/2.2.0/set.rb:283:in `each_key'
/home/kaspar/.rbenv/versions/2.2.0/lib/ruby/2.2.0/set.rb:283:in `each'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:41:in `_render_to_body_with_renderer'
actionpack (4.2.0) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.0) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/kaspar/.rbenv/versions/2.2.0/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.0) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:40:in `render'
responders (2.1.0) lib/action_controller/responder.rb:258:in `display'
responders (2.1.0) lib/action_controller/responder.rb:212:in `api_behavior'
responders (2.1.0) lib/action_controller/responder.rb:191:in `rescue in to_format'
responders (2.1.0) lib/action_controller/responder.rb:185:in `to_format'
responders (2.1.0) lib/action_controller/responder.rb:163:in `respond'
responders (2.1.0) lib/action_controller/responder.rb:156:in `call'
responders (2.1.0) lib/action_controller/respond_with.rb:203:in `respond_with'
app/controllers/users_controller.rb:73:in `feed'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.1) lib/rack/etag.rb:24:in `call'
rack (1.6.1) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.1) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
passenger (5.0.7) lib/phusion_passenger/rack/thread_handler_extension.rb:89:in `process_request'
passenger (5.0.7) lib/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
passenger (5.0.7) lib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
passenger (5.0.7) lib/phusion_passenger/request_handler.rb:414:in `block (3 levels) in start_threads'
passenger (5.0.7) lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
This error only occurs when I attempt to throw an array of Medium to the Serializer. With only one Medium I get no errors and the result is this:
As you can see it has all the attributes I wanted it to have in the serializer and it managed to fetch the info into all the attributes with no problems.
Why does this problem occur only when I do the same thing with an array or same objects?
I import a csv file into my DB and i have a error when I update it.
My error :
undefined method `first' for nil:NilClass
on line "if agent.update(line)"
My model :
def self.import_agent(file)
fallback = {:counter => 0}
CSV.foreach(file.path, :col_sep => "\t", :headers => true, :quote_char => "\x00", :encoding => 'windows-1251:utf-8') do |row|
line = Hash.new
row.to_hash.each_pair do |k,v|
row ={k.downcase.gsub("agent_", "") => v}
line = line.deep_merge(row)
end
agent = Agent.find_or_initialize_by(code:line["code"])
if agent.update(line)
fallback[:counter] += 1
end
end
return fallback
end
My Controller :
def import_agent
#file = params[:file]
fallback = Import.import_agent(#file)
redirect_to root_path, notice: 'File successfully uploaded, '+fallback[:counter].to_s+' line are added/updated !'
end
Error Log :
Started POST "/import_agent" for 127.0.0.1 at 2015-03-30 11:06:18 +0200
Processing by ImportsController#import_agent as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"pF1GsZ+Z+9tHmiw6k47Y7T7Sjn1ka1bHZqMqwWbBO2QIHBIz2VX9F7kPGP0CyYT6xu3nJnANJdGjDCtE0eISjw==", "file"=>#<ActionDispatch::Http::UploadedFile:0x007ff3d9fccba8 #tempfile=#<Tempfile:/var/folders/xw/pqcy6hjd59x29wf0wqcbhp1h0000gn/T/RackMultipart20150330-7818-f99zac.csv>, #original_filename="EXPORT_AGENT.csv", #content_type="text/csv", #headers="Content-Disposition: form-data; name=\"file\"; filename=\"EXPORT_AGENT.csv\"\r\nContent-Type: text/csv\r\n">, "commit"=>"Import Agent CSV"}
Agent Load (0.3ms) SELECT "agents".* FROM "agents" WHERE "agents"."code" = ? LIMIT 1 [["code", "AG001"]]
(0.1ms) begin transaction
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 62ms
NoMethodError - undefined method `first' for nil:NilClass:
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:114:in `find_parameter_position'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:103:in `block in extract_callstack_for_multiparameter_attributes'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:98:in `extract_callstack_for_multiparameter_attributes'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:76:in `assign_multiparameter_attributes'
activerecord (4.2.0) lib/active_record/attribute_assignment.rb:46:in `assign_attributes'
activerecord (4.2.0) lib/active_record/persistence.rb:249:in `block in update'
activerecord (4.2.0) lib/active_record/transactions.rb:347:in `block in with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:220:in `transaction'
activerecord (4.2.0) lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
activerecord (4.2.0) lib/active_record/persistence.rb:248:in `update'
app/models/import.rb:67:in `block in import_agent'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1739:in `each'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1122:in `block in foreach'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1273:in `open'
/Users/gregoryfrerot/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/csv.rb:1121:in `foreach'
app/models/import.rb:60:in `import_agent'
app/controllers/imports_controller.rb:16:in `import_agent'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
bullet (4.14.4) lib/bullet/rack.rb:12:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
thin (1.6.3) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.3) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.3) lib/thin/connection.rb:53:in `process'
thin (1.6.3) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.5) lib/eventmachine.rb:187:in `run'
thin (1.6.3) lib/thin/backends/base.rb:73:in `start'
thin (1.6.3) lib/thin/server.rb:162:in `start'
rack (1.6.0) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.0) lib/rack/server.rb:286:in `start'
railties (4.2.0) lib/rails/commands/server.rb:80:in `start'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.0) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'
Thanks for your help and sorry for my english.
Use find_or_create_by instead of find_or_initialize_by, since the latter does not insert new record into database.
I am new to Rails so pardon if this question is relatively simple - I went through all the other similar errors on SO and no solutions were of use.
I am trying to print a list of ingredients from this api call and getting the error Rails: undefined method 'ingredients' for nil:NilClass. Any help is appreciated!
My code snippets are:
about page:
<% content_for :title do %>About<% end %>
<h3>About the Website</h3>
<p>
This web application was created with
<%= link_to('Rails Composer', 'http://railsapps.github.io/rails-composer/') %>
from the <%= link_to('RailsApps project', 'http://railsapps.github.io/') %>.
Ingredients are <%= #recommendations.ingredients %>
</p>
model:
class Recommendations
require 'httparty'
attr_accessor :matches, :ingredients
def fetch_recipe
encoded_url = URI.encode("http://api.yummly.com/v1/api/recipes?_app_id=ca19779e&_app_key=125204344682094834d68637a8222adf&q=chicken&allowedCourse[]=course^course-Lunch&maxResult=100&start=1")
parsed_url = URI.parse(encoded_url)
HTTParty.get(parsed_url)
end
def initialize
recipe_hash = fetch_recipe
assign_values(recipe_hash)
end
def assign_values(recipe_hash)
recipe_response = recipe_hash.parsed_response['matches'][0]
self.ingredients = recipe_response['ingredients']
end
end
controller:
class RecommendationsController < ApplicationController
def home
#recommendations = Recommendations.new
end
end
logs:
Started GET "/pages/about" for 127.0.0.1 at 2014-07-28 17:43:40 -0700
Processing by HighVoltage::PagesController#show as HTML
Parameters: {"id"=>"about"}
Rendered pages/about.html.erb within layouts/application (1.0ms)
Completed 500 Internal Server Error in 4ms
NoMethodError - undefined method `ingredients' for nil:NilClass:
app/views/pages/about.html.erb:7:in `_app_views_pages_about_html_erb___310183375408592724_70240131703120'
actionview (4.1.2) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.2) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.2) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.2) lib/action_view/template.rb:143:in `render'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
actionview (4.1.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.2) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.2) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.2) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.2) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.2) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.2) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.2) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.2) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.1.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:40:in `render'
high_voltage (2.2.0) app/controllers/concerns/high_voltage/static_page.rb:28:in `show'
actionpack (4.1.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.2) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.2) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.2) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.2) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.2) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.2) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.2) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.2) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.2) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.2) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.2) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:82:in `call'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.2) lib/action_dispatch/routing/route_set.rb:678:in `call'
bullet (4.12.0) lib/bullet/rack.rb:10:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/headers.rb:16:in `call'
meta_request (0.3.3) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.2) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.2) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.2) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets'
actionpack (4.1.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.2) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.2) lib/rails/engine.rb:514:in `call'
railties (4.1.2) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.6.2) lib/thin/connection.rb:84:in `catch'
thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.6.2) lib/thin/connection.rb:53:in `process'
thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
thin (1.6.2) lib/thin/server.rb:162:in `start'
rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
rack (1.5.2) lib/rack/server.rb:264:in `start'
railties (4.1.2) lib/rails/commands/server.rb:69:in `start'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:81:in `block in server'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:76:in `tap'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:76:in `server'
railties (4.1.2) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
railties (4.1.2) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:8:in `require'
bin/rails:8:in `<top (required)>'
spring (1.1.3) lib/spring/client/rails.rb:27:in `load'
spring (1.1.3) lib/spring/client/rails.rb:27:in `call'
spring (1.1.3) lib/spring/client/command.rb:7:in `call'
spring (1.1.3) lib/spring/client.rb:26:in `run'
spring (1.1.3) bin/spring:48:in `<top (required)>'
spring (1.1.3) lib/spring/binstub.rb:11:in `load'
spring (1.1.3) lib/spring/binstub.rb:11:in `<top (required)>'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
bin/spring:16:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
class RecommendationsController < ApplicationController
def home
#recommendations = Recommendations.new
end
def about
#recommendations = Recommendations.new
end
end
add the recommendations instantiation to your about action too.
Better yet, refactor it into a method:
class RecommendationsController < ApplicationController
before_filter :new_recommendation, :only =>[:home, :about]
private
def new_recommentation
#recommendations = Recommendations.new
end
end
Ingredients of nil can, most logically, be also nil. Solve your problem by defining
def nil.ingredients
nil
end