You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rails 5 API: undefined method `helper_method' for ActionController::API:Class (NoMethodError) #3690
@ballPointPenguin, checked your fix. And yes, now, helper_method doesn't appear, but still devise doesn't work, because devise defines a lot of methods which behave as a helper method, for e.g.: authenticate_user!, current_user.
Any ideas, how it could be fixed/done?
Thanks
@nahaylo unfortunately, no. I haven't spent the effort getting devise working this way, beyond just clearing the initial failure addressed here.
IMO, more work could be done on devise to make it "api-friendly", so to speak.
Also, I have made devise work with Sinatra before, with surprisingly little monkey-patching, but it would still have been nicer if this was supported from the start. If anyone is planning on overhauling devise to be more RailsApi friendly, I strongly encourage you to focus on a more generalized approach of making it more friendly to Rack-based applications in general. Please let me know if I can help out, especially in identifying where it needed to be tweaked for Sinatra.
I had this working ( helper_method :authenticate_token!, :current_user ) and then swapped out jbuilder for active_model_serializers. I got the error noted above so I added back jbuilder and now my api is working as expected with JWT.
Activity
jeffdill2 commentedon Aug 9, 2015
@ballPointPenguin have you found any resolution or workaround for this issue?
ballPointPenguin commentedon Aug 11, 2015
@jeffdill2 this is working for me rails/rails#21151,
but it may be that a devise-side solution would be nicer.
FanaHOVA commentedon Aug 20, 2015
@ballPointPenguin Just used your Rails 5 fork and it works perfectly, thanks a lot for the fix.
ballPointPenguin commentedon Aug 20, 2015
@FanaHOVA glad I could help 😄
nahaylo commentedon Aug 27, 2015
@ballPointPenguin, checked your fix. And yes, now,
helper_methoddoesn't appear, but still devise doesn't work, because devise defines a lot of methods which behave as a helper method, for e.g.: authenticate_user!, current_user.Any ideas, how it could be fixed/done?
Thanks
ballPointPenguin commentedon Aug 27, 2015
@nahaylo unfortunately, no. I haven't spent the effort getting devise working this way, beyond just clearing the initial failure addressed here.
IMO, more work could be done on devise to make it "api-friendly", so to speak.
jeffdill2 commentedon Aug 27, 2015
@ballPointPenguin @nahaylo if you guys need another solution, I've been using https://github.com/simplabs/rails_api_auth and it's working very well. Very lightweight - i.e. well-suited for an API-only application.
betesh commentedon Aug 31, 2015
PR #3732 fixes the helper_method issue.
Also, I have made devise work with Sinatra before, with surprisingly little monkey-patching, but it would still have been nicer if this was supported from the start. If anyone is planning on overhauling devise to be more RailsApi friendly, I strongly encourage you to focus on a more generalized approach of making it more friendly to Rack-based applications in general. Please let me know if I can help out, especially in identifying where it needed to be tweaked for Sinatra.
lucasmazza commentedon Sep 26, 2015
Closed by #3732.
dizo1 commentedon Jun 4, 2017
Having the same issue could someone help?
dizo1 commentedon Jun 4, 2017
2017-06-04 03:19:52 +0000: Rack app error handling request { GET / }
#<NoMethodError: undefined method
helper_method' for ActionController::API:Class> /usr/local/rvm/gems/ruby-2.3.3/gems/google-webfonts-rails-0.0.1/lib/google-webfonts/rails/helpers.rb:7:inblock in module:Helpers'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/concern.rb:120:in
class_eval' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/concern.rb:120:inappend_features'/usr/local/rvm/gems/ruby-2.3.3/gems/google-webfonts-rails-0.0.1/lib/google-webfonts-rails.rb:9:in
include' /usr/local/rvm/gems/ruby-2.3.3/gems/google-webfonts-rails-0.0.1/lib/google-webfonts-rails.rb:9:inblock in <top (required)>'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:43:in
instance_eval' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:43:inexecute_hook'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:50:in
block in run_load_hooks' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:49:ineach'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:49:in
run_load_hooks' /usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_controller/api.rb:145:inclass:API'/usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_controller/api.rb:88:in
<module:ActionController>' /usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_controller/api.rb:5:in<top (required)>'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in
require' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:inblock in require'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in
load_dependency' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:inrequire'/usr/local/rvm/gems/ruby-2.3.3/gems/jbuilder-2.6.4/lib/jbuilder/railtie.rb:20:in
block (2 levels) in <class:Railtie>' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:43:ininstance_eval'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:43:in
execute_hook' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:50:inblock in run_load_hooks'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:49:in
each' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/lazy_load_hooks.rb:49:inrun_load_hooks'/usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_controller/base.rb:269:in
<class:Base>' /usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_controller/base.rb:164:inmodule:ActionController'/usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_controller/base.rb:5:in
<top (required)>' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:inrequire'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in
block in require' /usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:inload_dependency'/usr/local/rvm/gems/ruby-2.3.3/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in
require' /usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_dispatch/middleware/static.rb:77:inext'/usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_dispatch/middleware/static.rb:33:in
match?' /usr/local/rvm/gems/ruby-2.3.3/gems/actionpack-5.0.3/lib/action_dispatch/middleware/static.rb:130:incall'/usr/local/rvm/gems/ruby-2.3.3/gems/rack-2.0.3/lib/rack/sendfile.rb:111:in
call' /usr/local/rvm/gems/ruby-2.3.3/gems/railties-5.0.3/lib/rails/engine.rb:522:incall'/usr/local/rvm/gems/ruby-2.3.3/gems/puma-3.8.2/lib/puma/configuration.rb:224:in
call' /usr/local/rvm/gems/ruby-2.3.3/gems/puma-3.8.2/lib/puma/server.rb:600:inhandle_request'/usr/local/rvm/gems/ruby-2.3.3/gems/puma-3.8.2/lib/puma/server.rb:435:in
process_client' /usr/local/rvm/gems/ruby-2.3.3/gems/puma-3.8.2/lib/puma/server.rb:299:inblock in run'/usr/local/rvm/gems/ruby-2.3.3/gems/puma-3.8.2/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
abadfish commentedon Sep 20, 2017
I had this working ( helper_method :authenticate_token!, :current_user ) and then swapped out jbuilder for active_model_serializers. I got the error noted above so I added back jbuilder and now my api is working as expected with JWT.