pitr / angular-rails-templates

Use your angular templates with rails' asset pipeline
https://rubygems.org/gems/angular-rails-templates
MIT License
566 stars 169 forks source link

How to use Devise helper on template? #153

Closed ohmygodvt95 closed 5 years ago

ohmygodvt95 commented 7 years ago

I want to use some functions in Devise Helper: current_user, user_signed_in? In the template. I tried but failed.

Rails.application.config.after_initialize to
   Rails.application.assets.context_class.class_eval to
     Include ApplicationHelper
     Include ActionView :: Helpers
     Include Rails.application.routes.url_helpers
   End
End

I was able to use the path function, link_to ... but with devise is not done. who can help me?. thank you.

fourcolors commented 6 years ago

👍 I could use this too.

Looooong commented 5 years ago

If you are using Sprocket 3, the interface is changed like this (reference):

Rails.application.config.assets.configure do |env|
  env.context_class.class_eval do
    include Devise::Controllers::Helpers
  end
end

Also, Devise helpers are defined in Devise::Controllers::Helpers.