source sequence is illegal/malformed utf-8 when including GON gem? - ruby-on-rails

I am working with Ruby 2.3.3, Rails 5.1.5 and using the RubyMine (JetBrains) IDE and I am working the gon gem to send data to javascript. In my application.html.erb I am setting the <%= include_gon %> in the head (as specified by the gon documentation) and I am getting the illegal/malformed utf-8 exception. I ran this same code on C9 with Ruby 2.4.1 and Rails 5.1.4 with no error.
Here is the full stack trace:
activesupport (5.1.6) lib/active_support/core_ext/object/json.rb:36:in `to_json'
activesupport (5.1.6) lib/active_support/core_ext/object/json.rb:36:in `to_json'
activesupport (5.1.6) lib/active_support/json/encoding.rb:55:in `to_json'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/json/common.rb:224:in `generate'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/json/common.rb:224:in `generate'
activesupport (5.1.6) lib/active_support/json/encoding.rb:100:in `stringify'
activesupport (5.1.6) lib/active_support/json/encoding.rb:33:in `encode'
activesupport (5.1.6) lib/active_support/json/encoding.rb:20:in `encode'
activesupport (5.1.6) lib/active_support/core_ext/object/json.rb:39:in `to_json'
multi_json (1.13.1) lib/multi_json/adapters/json_common.rb:19:in `dump'
multi_json (1.13.1) lib/multi_json/adapter.rb:25:in `dump'
multi_json (1.13.1) lib/multi_json.rb:139:in `dump'
gon (6.2.0) lib/gon/json_dumper.rb:4:in `dump'
gon (6.2.0) lib/gon/base.rb:93:in `to_json'
gon (6.2.0) lib/gon/base.rb:77:in `render_variable'
gon (6.2.0) lib/gon/base.rb:51:in `block in formatted_data'
gon (6.2.0) lib/gon/base.rb:51:in `each'
gon (6.2.0) lib/gon/base.rb:51:in `map'
gon (6.2.0) lib/gon/base.rb:51:in `formatted_data'
gon (6.2.0) lib/gon/base.rb:24:in `render_data'
gon (6.2.0) lib/gon/helpers.rb:5:in `include_gon'
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__726524811_120260856'
actionview (5.1.6) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.6) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.6) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.6) lib/action_view/template.rb:155:in `render'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:64: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'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.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:34:in `cleanup_view_runtime'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:43:in `render'
actionpack (5.1.6) lib/action_controller/metal/implicit_render.rb:33:in `default_render'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
rack (2.0.4) lib/rack/etag.rb:25:in `call'
rack (2.0.4) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.4) lib/rack/head.rb:12:in `call'
rack (2.0.4) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.4) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.11.3) lib/puma/configuration.rb:225:in `call'
puma (3.11.3) lib/puma/server.rb:624:in `handle_request'
puma (3.11.3) lib/puma/server.rb:438:in `process_client'
puma (3.11.3) lib/puma/server.rb:302:in `block in run'
puma (3.11.3) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
I have been searching all over the internet for a solution but this dilemma seems to be localized to me. Also, the GemFile does have the gem 'gon' line and I performed a bundle install and update. I have also tried to run this locally on Ruby 2.4.3 and the same error persists. Please help.

Related

Issue Passing parameters from erb template to controller in Rails

I am trying to call a method in view template from its respective controller which is acting weirdly based on different conditions.
PLease note I have tried this after getting failure on this
Triply nested model's form in rails showing error
First of all the controller method is defined as ->
helper_method :find_feature
def find_feature(fid)
#project.features.find(fid)
end
And the view file code where this method is called ->
<% #project.features.each do |fet| %>
<%= "#{fet.name} #{fet.id} " %> #It does work!!
<%= render partial: "taskform",locals: { fetr: find_feature(fet.id) } %>
<% end %>
This throws error as Couldn't find Feature without an ID
in the screenshot islt is shown params[:id] is used that is not right sorry for that I have used the method which is written above as find_feature(fid) very sorry I will update the screenshot once I get to my mqchine
**
the error shows Couldn't find a feature without an id when called by find_feature(fet.id)
**
BUt when I explicitly test with an id, manually, like->
<%= render partial: "taskform", locals: { fetr: find_feature(7) } %>
This works !
Full stack trace-
activerecord (5.2.3) lib/active_record/relation/finder_methods.rb:433:in `find_with_ids'
activerecord (5.2.3) lib/active_record/relation/finder_methods.rb:69:in `find'
activerecord (5.2.3) lib/active_record/associations/collection_association.rb:100:in `find'
activerecord (5.2.3) lib/active_record/associations/collection_proxy.rb:140:in `find'
app/controllers/projects_controller.rb:7:in `find_feature'
actionpack (5.2.3) lib/abstract_controller/helpers.rb:67:in `find_feature'
app/views/projects/show.html.erb:66:in `block in _app_views_projects_show_html_erb__3383934460746758134_70317115637280'
activerecord (5.2.3) lib/active_record/relation/delegation.rb:71:in `each'
activerecord (5.2.3) lib/active_record/relation/delegation.rb:71:in `each'
app/views/projects/show.html.erb:56:in `_app_views_projects_show_html_erb__3383934460746758134_70317115637280'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/ayan/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
actionpack (5.2.3) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/builder.rb:64:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
Request
Parameters:
{"id"=>"4"}
Can anyone suggests what is the reason of this behaviour ?
You are calling the find_feature with this code find_feature(fet.id), so you want to pass the id as a parameter.
Define the helper_method this way then:
def find_feature(fid)
#project.features.find(fid)
end
params[:fid] will look for a request parameter with the key fid in the request's params hash, you are passing a specific value to the method when you call it.
EDIT: Anyway, I'm not sure why are you doing that, you already have the feature object on the fet variable inside the loop, just do this:
<%= render partial: "taskform",locals: { fetr: fet } %>
error shows method calling with parmas[:fid], but you defined method as find_feature(fid) for finding feature , so there must be other method which is overriding , try it by giving different name like find_project_features it will work

Rails: Unable to create a Global ID for Model without a model id

I am getting the following error from a Rails app:
URI::GID::MissingModelIdError in Treatment
Unable to create a Global ID for Treatment without a model id.
globalid (0.4.1) lib/global_id/uri/gid.rb:167:in `validate_model_id'
globalid (0.4.1) lib/global_id/uri/gid.rb:151:in `set_model_components'
globalid (0.4.1) lib/global_id/uri/gid.rb:136:in `check_path'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:819:in `path='
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:193:in `initialize'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:138:in `new'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:138:in `build'
globalid (0.4.1) lib/global_id/uri/gid.rb:92:in `build'
globalid (0.4.1) lib/global_id/uri/gid.rb:68:in `create'
globalid (0.4.1) lib/global_id/global_id.rb:15:in `create'
globalid (0.4.1) lib/global_id/identification.rb:8:in `to_global_id'
activestorage (0.1) lib/active_storage/attached/one.rb:5:in `attachment'
activestorage (0.1) lib/active_storage/attached/one.rb:13:in `attached?'
app/views/treatments/_form.html.erb:52:in `block in _app_views_treatments__form_html_erb___357661333339907035_70285432864960'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:39:in `block in capture'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:203:in `with_output_buffer'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:39:in `capture'
actionview (5.1.6) lib/action_view/helpers/form_helper.rb:450:in `form_for'
app/views/treatments/_form.html.erb:1:in `_app_views_treatments__form_html_erb___357661333339907035_70285432864960'
actionview (5.1.6) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.6) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.6) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.6) lib/action_view/template.rb:155:in `render'
actionview (5.1.6) lib/action_view/renderer/partial_renderer.rb:342:in `block in render_partial'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.1.6) lib/action_view/renderer/partial_renderer.rb:331:in `render_partial'
actionview (5.1.6) lib/action_view/renderer/partial_renderer.rb:310:in `render'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (5.1.6) lib/action_view/helpers/rendering_helper.rb:35:in `render'
app/views/treatments/new.html.erb:42:in `_app_views_treatments_new_html_erb___2682657173693281074_70285432951520'
actionview (5.1.6) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.6) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.6) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.6) lib/action_view/template.rb:155:in `render'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:52:in `block (2 levels) in render_template'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:51:in `block in render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:59: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'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.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'
actionpack (5.1.6) lib/action_controller/metal/implicit_render.rb:33:in `default_render'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.5) lib/rack/etag.rb:25:in `call'
rack (2.0.5) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.5) lib/rack/head.rb:12:in `call'
rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
I am getting this error when I try to load either the new or create method.
def new
#treatment = Treatment.new
end
def create
#treatment = Treatment.create!(treatment_params)
if #treatment.save
redirect_to root_path, notice: "Treatment added successfully"
else
render 'new', notice: "Oh no, Zuber u silly man!"
end
end
The error is generated by the Global ID gem
Seems to be a problem with the #treatment variable. When trying to use this in the view I get the error, but also when trying to save the data to the database.
The model looks like this (not sure why there are 6 separate images rather than many):
class Treatment < ApplicationRecord
extend FriendlyId
friendly_id :link, use: :slugged
validates :speciality,:link,:price,:duration,:image, presence: true
validates :content, presence: true, length: { minimum: 15}
has_one_attached :image
has_one_attached :image1
has_one_attached :image2
has_one_attached :image3
has_one_attached :image4
has_one_attached :image5
has_one_attached :image6
end
And the schema:
create_table "treatments", force: :cascade do |t|
t.string "category"
t.string "speciality"
t.text "content"
t.integer "price"
t.string "duration"
t.string "link"
t.string "image"
t.string "image1"
t.string "image2"
t.string "image3"
t.string "image4"
t.string "image5"
t.string "image6"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "slug"
t.index ["slug"], name: "index_treatments_on_slug", unique: true
end
I'm pretty new to Rails and am looking at this on behalf of a friend who is even newer, and I don't know what he may or may not have done previously to cause the error.
I hope someone can help, after a couple of hours of searching I couldn't find anything helpful.
Thanks!
EDIT:
I think this is something to do with Active Storage, as if I try to use #treatments.image.attached? in the view I get an error, but if just #treatments.image is used there is no error.
After realising that the app is in Rails 5.1.6, I decided to get rid of Active Storage in favour of the Paperclip gem. The error is no more!

Rails i18n and EasyTranslate

I am using a locale :cn which is not recognized by EasyTranslate. I am trying to create the if in the controller such as:
def index
#events = Events.all
if I18n.locale == :cn
#locale = ":zh-CN"
else
#locale = I18n.locale
end
end
so that I can use the following in my view:
<%= check_box_tag "by_cities[]", city %> <%= EasyTranslate.translate(city, :to => #locale, :key => #key) %>
BUt I get an EasyTranslate:EasyTranslateException in Event#index Invalid Value
How can i get EasyTranslate to take the new locale just for this method please?
Thank you
Et
Application Trace | Framework Trace | Full Trace
easy_translate (0.5.1) lib/easy_translate/request.rb:47:in `perform_raw'
easy_translate (0.5.1) lib/easy_translate/translation.rb:34:in `request_translations'
easy_translate (0.5.1) lib/easy_translate/threadable.rb:24:in `block in threaded_process'
easy_translate (0.5.1) lib/easy_translate/threadable.rb:24:in `map'
easy_translate (0.5.1) lib/easy_translate/threadable.rb:24:in `threaded_process'
easy_translate (0.5.1) lib/easy_translate/translation.rb:20:in `translate'
app/views/events/index.html.erb:21:in `block (2 levels) in _app_views_events_index_html_erb___49110152348777287_70221206769120'
app/views/events/index.html.erb:19:in `each'
app/views/events/index.html.erb:19:in `block in _app_views_events_index_html_erb___49110152348777287_70221206769120'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:39:in `block in capture'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:203:in `with_output_buffer'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:39:in `capture'
actionview (5.1.6) lib/action_view/helpers/form_tag_helper.rb:70:in `form_tag'
app/views/events/index.html.erb:15:in `_app_views_events_index_html_erb___49110152348777287_70221206769120'
actionview (5.1.6) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.6) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.6) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.6) lib/action_view/template.rb:155:in `render'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:52:in `block (2 levels) in render_template'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:51:in `block in render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:59: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'
/Users/etienne/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.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'
searchkick (3.1.2) lib/searchkick/logging.rb:214: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'
wicked_pdf (1.1.0) lib/wicked_pdf/pdf_helper.rb:42:in `render_with_wicked_pdf'
wicked_pdf (1.1.0) lib/wicked_pdf/pdf_helper.rb:27:in `render'
actionpack (5.1.6) lib/action_controller/metal/implicit_render.rb:33:in `default_render'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
searchkick (3.1.2) lib/searchkick/logging.rb:209:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.0.6) lib/rack/etag.rb:25:in `call'
rack (2.0.6) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.6) lib/rack/head.rb:12:in `call'
rack (2.0.6) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.6) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
rollbar (2.18.0) lib/rollbar/middleware/rails/rollbar.rb:24:in `block in call'
rollbar (2.18.0) lib/rollbar.rb:146:in `scoped'
rollbar (2.18.0) lib/rollbar/middleware/rails/rollbar.rb:22:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
rollbar (2.18.0) lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
Very simple actually :
In the controller :
if I18n.locale == :cn
#locale ="zh-CN"
else
#locale = (":"+ (I18n.locale).to_s)
end
In the view:
<%= check_box_tag "by_cities[]", city %> <%= EasyTranslate.translate(city, :to => #locale, :key => #key) %>

Rails/Sorcery: undefined method `remember_me_token=' for #<User ...>

I've been following the Sorcery tutorial to build simple password authentication for a new (blank) Rails app. I've followed it very closely except for translating the erb to haml as I go along.
Everything has worked fine except that when testing the logout function it throws an error that seems to stump Google (see title).
The application trace shows only
app/controllers/user_sessions_controller.rb:16:in `destroy'
highlighting the logout line in user_sessions_controller.rb:
def destroy
logout
redirect_to(:users, notice: 'Logged out!')
end
I'll dump the framework trace below (it means very little to me) and am very happy to provide further information if you let me know what would be helpful. Generic advice on how to debug this kind of error would also be welcome.
activemodel (5.1.6) lib/active_model/attribute_methods.rb:432:in `method_missing'
sorcery (0.12.0) lib/sorcery/adapters/active_record_adapter.rb:6:in `block in update_attributes'
sorcery (0.12.0) lib/sorcery/adapters/active_record_adapter.rb:5:in `each'
sorcery (0.12.0) lib/sorcery/adapters/active_record_adapter.rb:5:in `update_attributes'
sorcery (0.12.0) lib/sorcery/model/submodules/remember_me.rb:67:in `force_forget_me!'
sorcery (0.12.0) lib/sorcery/model/submodules/remember_me.rb:61:in `forget_me!'
sorcery (0.12.0) lib/sorcery/controller/submodules/remember_me.rb:34:in `forget_me!'
sorcery (0.12.0) lib/sorcery/controller.rb:149:in `block in before_logout!'
sorcery (0.12.0) lib/sorcery/controller.rb:149:in `each'
sorcery (0.12.0) lib/sorcery/controller.rb:149:in `before_logout!'
sorcery (0.12.0) lib/sorcery/controller.rb:69:in `logout'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
rack (2.0.5) lib/rack/etag.rb:25:in `call'
rack (2.0.5) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.5) lib/rack/head.rb:12:in `call'
rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.5) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.6.2) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.6.2) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `catch'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.11.4) lib/puma/configuration.rb:225:in `call'
puma (3.11.4) lib/puma/server.rb:632:in `handle_request'
puma (3.11.4) lib/puma/server.rb:446:in `process_client'
puma (3.11.4) lib/puma/server.rb:306:in `block in run'
puma (3.11.4) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Restarting the Rails server resolved the problem.

wrong number of arguments with impressionist and friendly_id

I'm getting a wrong number of arguments (given 2, expected 0..1) error when trying to track the model her views.
My Model:
class Codetip < ApplicationRecord
belongs_to :user
is_impressionable
validates :title, presence: true, length: { minimum: 4 }
validates :body, presence: true, length: { minimum: 4 }
validates :user_id, presence: true
extend FriendlyId
friendly_id :name, use: :slugged
end
Codetip controller:
As https://github.com/charlotte-ruby/impressionist suggested on section 4 under usage.
def show
#codetip = Codetip.friendly.find(params[:id])
impressionist(#codetip)
end
My show view:
<%= #codetip.impressionist_count %>
Next to that ive did everything that the wiki suggested: added the gem, bundled, generated the impressions table and migrated it.
Update 1
Stacktrace
activerecord (5.0.0.beta3) lib/active_record/associations/collection_proxy.rb:731:in `count'
impressionist (1.5.1) app/models/impressionist/impressionable.rb:47:in `impressionist_count'
app/views/codetips/show.html.erb:2:in `_app_views_codetips_show_html_erb__4508833467180784211_70228361271700'
actionview (5.0.0.beta3) lib/action_view/template.rb:158:in `block in render'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.0.0.beta3) lib/action_view/template.rb:348:in `instrument'
actionview (5.0.0.beta3) lib/action_view/template.rb:156:in `render'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.beta3) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (5.0.0.beta3) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (5.0.0.beta3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.0.0.beta3) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.0.0.beta3) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.0.0.beta3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.0.0.beta3) lib/action_controller/metal/renderers.rb:144:in `render_to_body'
actionpack (5.0.0.beta3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.0.0.beta3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:43:in `block (2 levels) in render'
activesupport (5.0.0.beta3) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/Etore/.rbenv/versions/2.3.0/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
activesupport (5.0.0.beta3) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:43:in `block in render'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
activerecord (5.0.0.beta3) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:42:in `render'
actionpack (5.0.0.beta3) lib/action_controller/metal/implicit_render.rb:19:in `default_render'
actionpack (5.0.0.beta3) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.0.0.beta3) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.0.0.beta3) lib/abstract_controller/base.rb:183:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.0.0.beta3) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.beta3) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/rescue.rb:27:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.0.beta3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.0.beta3) lib/abstract_controller/base.rb:128:in `process'
actionview (5.0.0.beta3) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.0.beta3) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.0.beta3) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.0.beta3) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.0.beta3) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.0.beta3) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.0.beta3) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.0.beta3) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.0.beta3) lib/action_dispatch/routing/route_set.rb:724:in `call'
actionview (5.0.0.beta3) lib/action_view/digestor.rb:12:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (2.0.0.alpha) lib/rack/etag.rb:25:in `call'
rack (2.0.0.alpha) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.0.alpha) lib/rack/head.rb:12:in `call'
rack (2.0.0.alpha) lib/rack/session/abstract/id.rb:220:in `context'
rack (2.0.0.alpha) lib/rack/session/abstract/id.rb:214:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.0.0.beta3) lib/active_record/query_cache.rb:36:in `call'
activerecord (5.0.0.beta3) lib/active_record/connection_adapters/abstract/connection_pool.rb:963:in `call'
activerecord (5.0.0.beta3) lib/active_record/migration.rb:558:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/reloader.rb:71:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.1.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.1.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.0.alpha) lib/rack/method_override.rb:22:in `call'
rack (2.0.0.alpha) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.0.beta3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/load_interlock.rb:13:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.0.alpha) lib/rack/sendfile.rb:111:in `call'
railties (5.0.0.beta3) lib/rails/engine.rb:522:in `call'
puma (3.0.2) lib/puma/configuration.rb:221:in `call'
puma (3.0.2) lib/puma/server.rb:561:in `handle_request'
puma (3.0.2) lib/puma/server.rb:406:in `process_client'
puma (3.0.2) lib/puma/server.rb:271:in `block in run'
puma (3.0.2) lib/puma/thread_pool.rb:111:in `block in spawn_thread'
Ive figured out what the problem was.
On my show page it should have been <%= #codetip.impressions.count %> instead of <%= #codetip.impressionist_count %>. This topic can be marked as resolved.
update the condition in gems file as app/models/impressionist/impressionable.rb
replace if Rails::VERSION::MAJOR == 4 with if Rails::VERSION::MAJOR >= 4
please refer https://github.com/charlotte-ruby/impressionist/issues/212

Resources