Reputation: 405
Where do I define authenticate!
to get custom authentication for Blazer?
I have this (uncommented) line in my config/blazer.yml
(as described in the README under Authentication > Other):
before_action: :authenticate!
When I refresh my app, I get this error:
NoMethodError at / undefined method 'authenticate!' for #<Blazer::QueriesController:0x007ffe26447830>
That class is defined by the Blazer gem. Am I supposed to add/redefine its authenticate!
method somehow?
I tried adding an initializers/blazer.rb
file where I defined:
class Blazer::QueriesController < Blazer::BaseController
def authenticate!
true
end
end
But now, when I click "New Query" in Blazer, I get this error:
NoMethodError in Blazer::Queries#new undefined method `errors' for nil:NilClass
Rails 4.2.5, Blazer 1.8.0
Upvotes: 0
Views: 696
Reputation: 8600
You should add your custom method into application_controller.rb
. You then put the name of the method into config/blazer.yml
to wire it up.
I would recommend using Devise
for authentication. The Devise wiki has a great starting article here. The engine and routes of blazer must also be protected as demonstrated here.
Upvotes: 2