Sprockets::Environment#path is deprecated
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/sprockets/helpers/rails_helper.rb:119:in `rewrite_asset_path'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/asset_paths.rb:29:in `compute_public_path'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/sprockets/helpers/rails_helper.rb:100:in `compute_public_path'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/sprockets/helpers/rails_helper.rb:67:in `asset_path'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/sprockets/helpers/rails_helper.rb:57:in `block in stylesheet_link_tag'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/sprockets/helpers/rails_helper.rb:47:in `collect'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/sprockets/helpers/rails_helper.rb:47:in `stylesheet_link_tag'
/home/yulong/one/app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___567393440_92926490'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/template.rb:144:in `block in render'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.1.0.rc6/lib/active_support/notifications.rb:55:in `instrument'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/template.rb:142:in `render'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/template_renderer.rb:52:in `render_with_layout'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/template_renderer.rb:38:in `render_template'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/template_renderer.rb:12:in `block in render'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/template_renderer.rb:9:in `render'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/renderer.rb:36:in `render_template'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_view/renderer/renderer.rb:17:in `render'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/abstract_controller/rendering.rb:120:in `_render_template'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_controller/metal/streaming.rb:250:in `_render_template'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/abstract_controller/rendering.rb:114:in `render_to_body'
/home/yulong/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.1.0.rc6/lib/action_controller/metal/renderers.rb:30:in `render_to_body'
Else, when i install rails, I got an error "file 'lib' not found", but i can't solve it and i think it's relative.
These deprecations, recently introduced in Sprockets, warnings fixed in rails-3.1.0-rc7. See https://github.com/rails/rails/issues/2598 for more detail.
Upgrade to the latest Rails 3.1.rc8, or you can wait for Rails 3.1 final that should be released by tomorrow.
Related
I installed the hotwire-rails gem and run rails hotwire:install, which seems to work fine.
When I call the method turbo_stream_from "posts" from a view, I receive the following error, which I don't understand at all.
undefined method `then' for "posts":String
In multiple examples I see a string being passed to the method turbo_stream_from, to identify the streamname. I tried checking the repo but I didn't find much based upon my knowledge of what I saw. Does anybody know what pieces I might be missing to get this working?
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:21:in `stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `block in stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `map'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:13:in `signed_stream_name'
turbo-rails (0.5.1) app/helpers/turbo/streams_helper.rb:20:in `turbo_stream_from'
app/views/forms/index.html.haml:6
actionview (6.0.3.5) lib/action_view/base.rb:274:in `_run'
actionview (6.0.3.5) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.3.5) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.3.5) lib/action_view/template.rb:385:in `instrument_render_template'
actionview (6.0.3.5) lib/action_view/template.rb:183:in `render'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:58:in `block (2 levels) in render_template'
actionview (6.0.3.5) lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.3.5) lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:57:in `block in render_template'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:65:in `render_with_layout'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:56:in `render_template'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.3.5) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.3.5) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.3.5) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.0.3.5) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.3.5) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.0.3.5) lib/action_controller/metal/streaming.rb:218:in `_render_template'
actionview (6.0.3.5) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.3.5) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.3.5) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.3.5) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.3.5) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.3.5) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/Users/renevanpelt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
activesupport (6.0.3.5) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:43:in `render'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:30:in `render'
actionpack (6.0.3.5) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (6.0.3.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.0.3.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.0.3.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:112:in `block in run_callbacks'
activesupport (6.0.3.5) lib/active_support/core_ext/time/zones.rb:66:in `use_zone'
app/controllers/dashboard_controller.rb:32:in `set_time_zone'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:121:in `block in run_callbacks'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:139:in `run_callbacks'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:136:in `process'
Update: I've generated a fresh rails 6 app and it works perfectly. The app that gives the error is just migrated from rails 5 to rails 6. Maybe that's where the difference between the two cases is.
Just run into the same issue today. Turns out I am using ruby 2.5 but then was introduced in ruby 2.6.
Upgrading ruby to 2.6.6 fixed the issue.
I'm encountering a weird error related to partials (happens in CI only). For some reason action view is not able to find a cached partial.
Things I've tried so far:
updating/downgrading gems
changing cache config in environments
checking if haml templates are valid
It seems to be pretty random, like a timing/caching issue. Any ideas how to narrow it down further?
#<ActionView::Template::Error: undefined method `_app_views_layouts__scripts_html_haml___2595795301995672650_69966270413140' for #<#<Class:0x00007f447a616578>:0x00007f4472804ab8>>
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/base.rb:274:in `_run'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/template.rb:185:in `block in render'
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:182:in `instrument'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/template.rb:385:in `instrument_render_template'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/template.rb:183:in `render'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:in `block in instrument'
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/local/bundle/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:in `instrument'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/partial_renderer.rb:346:in `render_partial'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/partial_renderer.rb:317:in `render'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/renderer.rb:65:in `render_partial_to_object'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/renderer/renderer.rb:53:in `render_partial'
/usr/local/bundle/gems/actionview-6.0.3.4/lib/action_view/helpers/rendering_helper.rb:38:in `render'
I'm currently in the middle of upgrading a Ruby on Rails 3 project to Ruby on Rails 4.0.
Several of my tests related to controllers are failing because specific files cannot be found when rendering the templates during the tests:
ActionView::Template::Error: No such file or directory
All these errors have the same in common, that they try to load files from the tmp/cache in the Rails application. This was working all fine under Rails 3.
Is something specific required for asset compilation under Rails 4 in tests?
# config/application.rb
# Enable the asset pipeline
config.assets.enabled = true
The above is not overwritten in our test environment, so I assume this remains enabled? And we used Sprockets in Rails 3 as well.
Rails : 4.0
Sprockets : 3.6
I'm probably missing something obvious, just can't find it...
Error output
test_0001_should show a form to upload attachments and display existing ones(AttachmentsControllerTest::#new):
ActionView::Template::Error: No such file or directory # rb_sysopen - /root/my_app/tmp/cache/assets/test/sprockets/v3.0/m7/m7YIr0duEvKhRldOP5LjpABJF7kd9H6aT5dCMyGnOl8.cache.47262198725000.3291.4516
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:278:in `initialize'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:278:in `open'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:278:in `atomic_write'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cache/file_store.rb:107:in `set'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cache.rb:212:in `set'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cache.rb:86:in `fetch'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:56:in `file_digest'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/unloaded_asset.rb:104:in `dependency_history_key'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:304:in `fetch_asset_from_dependency_cache'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `yield'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/environment.rb:30:in `find_asset'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:92:in `[]'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:123:in `asset_digest_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:76:in `compute_asset_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_url_helper.rb:132:in `asset_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:91:in `asset_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_url_helper.rb:234:in `javascript_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_tag_helper.rb:58:in `block in javascript_include_tag'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_tag_helper.rb:56:in `map'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_tag_helper.rb:56:in `javascript_include_tag'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:148:in `javascript_include_tag'
/root/my_app/app/views/layouts/attachments.html.erb:2:in `block in _app_views_layouts_attachments_html_erb___457563631613762413_47262336759680'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/haml-4.0.7/lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:38:in `capture'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/haml-4.0.7/lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:152:in `content_for'
/root/my_app/app/views/layouts/attachments.html.erb:1:in `_app_views_layouts_attachments_html_erb___457563631613762413_47262336759680'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/template.rb:143:in `block in render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `block in instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/template.rb:141:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/template_renderer.rb:17:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/renderer.rb:42:in `render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/renderer.rb:23:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:127:in `_render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/streaming.rb:219:in `_render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:120:in `render_to_body'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:97:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rendering.rb:16:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/core_ext/benchmark.rb:12:in `ms'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.13/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:40:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/base.rb:189:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rendering.rb:10:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/callbacks.rb:453:in `_run__64868443609262235__process_action__callbacks'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/callbacks.rb:80:in `run_callbacks'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/callbacks.rb:17:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rescue.rb:29:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `block in instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/base.rb:136:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:44:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:572:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:64:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/active_model_serializers-0.9.5/lib/action_controller/serialization_test_case.rb:25:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:472:in `get'
/root/my_app/test/functional/attachments_controller_test.rb:78:in `block (2 levels) in <class:AttachmentsControllerTest>'
EDIT
This is the file causing the error: app/views/layouts/attachments.html.erb
<%= content_for :head do %>
<%= javascript_include_tag 'attachments' %>
<% end %>
<%= render template: "layouts/standard_bootstrap" %>
The template is the following:
<!DOCTYPE html>
%html{lang: "en"}
%head
%script
= javascript_include_tag "/javascripts/jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"
= javascript_include_tag "/javascripts/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js"
= stylesheet_link_tag "/javascripts/jquery-ui-1.9.2.custom/css/flick/jquery-ui-1.9.2.custom.min.css"
= stylesheet_link_tag 'standard'
= stylesheet_link_tag '/stylesheets/bootstrap/css/bootstrap.min.css'
= stylesheet_link_tag '/stylesheets/bootstrap/css/bootstrap-datepicker.standalone.min.css'
= javascript_include_tag "standard_bootstrap_third_party.js"
= yield :head
%body
#content
= yield
Could it be that it's not finding one of the files in the template?
All the referenced files exist in the /public/javascripts folder.
I had the exact same issue when using parallel_tests,
fixed by adding the following to config/environments/test.rb:
config.cache_store = :file_store, Rails.root.join("tmp", "cache", "paralleltests#{ENV['TEST_ENV_NUMBER']}")
as mentioned in parallel tests wiki
I have a report that's available in HTML or PDF formats. Sometimes, I want to display an error message instead of the report. The error message should be wrapped in my application's usual layout.
This works fine if the request was for the HTML report, but if the PDF report was requested, I get "There was no default layout for MyController in #<ActionView::PathSet..."
My controller method looks like this:
def report
unless report_available?
render html: '<div class="error">Not available.</div>'.html_safe,
:status => 404, :layout => true
return
end
...
end
I've tried adding :formats => :html or :formats => [:html] to the call to render, but it has no effect. I've also tried setting params[:format] = 'html' before calling render, but that didn't help either.
How do I render a snippet of HTML using the default layout when the request was for report.pdf?
The full error message looks like:
There was no default layout for MyController in #<ActionView::PathSet:0x00007fd3b842c370 #paths=[#<ActionView::OptimizedFileSystemResolver:0x00007fd3d0776c20 #pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", #cache=#<ActionView::Resolver::Cache:0x7fd3d0776bf8 keys=1 queries=0>, #path="/var/www/apps/myapp/releases/1/app/views">]>
And the stack trace looks like:
actionview (5.1.6) lib/action_view/layouts.rb:420:in `_default_layout'
actionview (5.1.6) lib/action_view/layouts.rb:389:in `block in _layout_for_option'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:94:in `resolve_layout'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:74:in `find_layout'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:58:in `render_with_layout'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:50:in `render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (5.1.6) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.1.6) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.1.6) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.1.6) lib/action_controller/metal/renderers.rb:141:in `render_to_body'
actionpack (5.1.6) lib/abstract_controller/rendering.rb:24:in `render'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (5.1.6) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/rbenv/versions/2.4.3/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
activesupport (5.1.6) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:29:in `cleanup_view_runtime'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:43:in `render'
app/controllers/my_controller.rb:809:in `report'
I believe the problem is that it's looking for a layout with .pdf.erb instead of .html.erb, but I don't know how to change that.
What you need to do is redirect to 404 page with this as a flash notice.
If you don't have a 404 page, you'd need one anyway.
You have to set the request format of your action:
def report
request.format = :html
# ..
end
You can also use it in a before_action filter
class ApplicationController < ActionController::Base
before_action :set_default_response_format
protected
def set_default_response_format
request.format = :html
end
end
I have a Rails application and an Engine.
When i have config.eager_load= true in my environments/production.rb the app crashes giving the following error in the engine
FATAL: ActionView::Template::Error(undefined local variable or method `current_user' for #<#<Class:0x00000005812fe0>:0x00000005811e88>)
/var/www/rack_apps/manager/shared/vendor_bundle/ruby/2.1.0/gems/authorization_engine-0.1.0.SNAPSHOT.20140407182910/app/views/authorization_engine/authorizations/new.html.haml:26:in `__var_www_rack_apps_manager_shared_vendor_bundle_ruby_______gems_authorization_engine_______________________________app_views_authorization_engine_authorizations_new_html_haml__268041456534634533_46121540'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/template.rb:143:in `block in render'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:161:in `instrument'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/template.rb:141:in `render'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `block in instrument'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.0.4/lib/active_support/notifications.rb:159:in `instrument'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/template_renderer.rb:17:in `render'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/renderer.rb:42:in `render_template'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_view/renderer/renderer.rb:23:in `render'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:127:in `_render_template'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/streaming.rb:219:in `_render_template'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/abstract_controller/rendering.rb:120:in `render_to_body'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
vendor/bundle/ruby/2.1.0/gems/actionpack-4.0.4/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
But the same above seems to work if i set the config.eager_load = false
Is this normal ? ... I know you shouldn't be setting eager_load to false in production. Is there a way not to eager load the engine or have i got the entire concept wrong ?
I know it says undefined variable current_user but it picks it up perfectly when i run locally . Any suggestions or ideas would be awesome .Thanks
http://edgeguides.rubyonrails.org/configuring.html
The official documentation says:
config.eager_load when true, eager loads all registered config.eager_load_namespaces. This includes your application, engines, Rails frameworks and any other registered namespace.
To answer that question correct we need to know what are you using for sessions, like devise gem or something. But I guess you use some gem for it and if you say that locally your application running without errors, so maybe there is difference in your gem versions locally and on server? You could update gem and it broke something for example. So I advise you to start with this.