crimethinc / website

Ruby on Rails app that powers crimethinc.com
https://crimethinc.com
Creative Commons Zero v1.0 Universal
103 stars 31 forks source link

NoMethodError when requesting an image #73

Closed gesa closed 7 years ago

gesa commented 7 years ago

an image in the assets directory is returning this NoMethodError instead of loading like i asked it to

NoMethodError in PagesController#show

   # no layout
    if @article.hide_layout?
      render text: @article.content, layout: false
    else
      render "articles/show"
Full Trace ``` app/controllers/pages_controller.rb:6:in `show' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/base.rb:188:in `process_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/rendering.rb:30:in `process_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:126:in `call' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:455:in `call' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:101:in `__run_callbacks__' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:90:in `run_callbacks' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/callbacks.rb:19:in `process_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/rescue.rb:20:in `process_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/notifications.rb:164:in `block in instrument' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/notifications.rb:164:in `instrument' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal/params_wrapper.rb:248:in `process_action' vendor/gems/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/abstract_controller/base.rb:126:in `process' vendor/gems/ruby/2.3.0/gems/actionview-5.0.0.1/lib/action_view/rendering.rb:30:in `process' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal.rb:190:in `dispatch' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_controller/metal.rb:262:in `dispatch' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:50:in `dispatch' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:32:in `serve' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/journey/router.rb:39:in `block in serve' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/journey/router.rb:26:in `each' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/journey/router.rb:26:in `serve' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:725:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/etag.rb:25:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/conditional_get.rb:25:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/head.rb:12:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:222:in `context' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:216:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/cookies.rb:613:in `call' vendor/gems/ruby/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:552:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_call_callbacks' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:90:in `run_callbacks' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/callbacks.rb:36:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/executor.rb:12:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/remote_ip.rb:79:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call' vendor/gems/ruby/2.3.0/gems/web-console-3.3.1/lib/web_console/middleware.rb:131:in `call_app' vendor/gems/ruby/2.3.0/gems/web-console-3.3.1/lib/web_console/middleware.rb:28:in `block in call' vendor/gems/ruby/2.3.0/gems/web-console-3.3.1/lib/web_console/middleware.rb:18:in `catch' vendor/gems/ruby/2.3.0/gems/web-console-3.3.1/lib/web_console/middleware.rb:18:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' vendor/gems/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/rack/logger.rb:36:in `call_app' vendor/gems/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/rack/logger.rb:24:in `block in call' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:70:in `block in tagged' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:26:in `tagged' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/tagged_logging.rb:70:in `tagged' vendor/gems/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/rack/logger.rb:24:in `call' vendor/gems/ruby/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/rails/quiet_assets.rb:11:in `block in call' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/logger_silence.rb:20:in `silence' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/logger.rb:63:in `block (3 levels) in broadcast' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/logger_silence.rb:20:in `silence' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/logger.rb:61:in `block (2 levels) in broadcast' vendor/gems/ruby/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/rails/quiet_assets.rb:11:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/request_id.rb:24:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/method_override.rb:22:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call' vendor/gems/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/executor.rb:12:in `call' vendor/gems/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/middleware/static.rb:136:in `call' vendor/gems/ruby/2.3.0/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call' vendor/gems/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:522:in `call' vendor/gems/ruby/2.3.0/gems/puma-3.6.0/lib/puma/configuration.rb:225:in `call' vendor/gems/ruby/2.3.0/gems/puma-3.6.0/lib/puma/server.rb:578:in `handle_request' vendor/gems/ruby/2.3.0/gems/puma-3.6.0/lib/puma/server.rb:415:in `process_client' vendor/gems/ruby/2.3.0/gems/puma-3.6.0/lib/puma/server.rb:275:in `block in run' vendor/gems/ruby/2.3.0/gems/puma-3.6.0/lib/puma/thread_pool.rb:116:in `block in spawn_thread' ```

Request Parameters: {"path"=>"assets/images/crimethinc-header-logo", "format"=>"png"}

veganstraightedge commented 7 years ago

I think using asset_path will get you what you want.

asset_path("crimethinc-header-logo.png")

veganstraightedge commented 7 years ago

This seems resolved. Closing.