Rails: Before process_action callback :authenticate_user! has not been defined
Twilio developer evangelist here.
It looks like this was a problem that Rails 5 seems to have introduced. If the filter hasn't been defined by the time it is used in a controller it will raise an error. This was discovered in the Clearance project too.
Their fix was to pass the raise: false
option to skip_before_filter
:
class MessagesController < ApplicationController
skip_before_filter :verify_authenticity_token
skip_before_filter :authenticate_user!, :only => "reply", :raise => false
end
Before process_action callback :require_no_authentication has not been defined
Here is the solution. I was not skipping the require_login method which I have made to check whether user has authentication_token or not
class ConfirmationsController < Devise::ConfirmationsController
skip_before_action :require_login!
def new
super
end
def create
super
end
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource)
respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }
end
end
private
def after_confirmation_path_for(resource_name, resource)
if signed_in?(resource_name)
signed_in_root_path(resource)
else
new_session_path(resource_name)
end
end
end
After updating to Rails 5 and Devise 4.0.0.rc1, the devise authenticate_user! method is not defined
I could identify the issue, in rails 5, there will be an exception if the skipping method is not defined at the time of calling unless we add :unless
condition.
skip_before_action and Rails 5
According to this thread
So your solution is to passActiveSupport::Callbacks#
skip_callback
now raises an ArgumentError if an unrecognized callback is removed.
raise: false
option to skip_before_action
:skip_before_action :redirect_heroku_user, raise: false
See the changelog for more info. How can I fix the Twilio::REST::RestError?
Hard to say with the level of detail given but usually there is an error in your secrets.yml file. Double check that our Twilio Keys are set properly.
Devise before_action : authentication exception
The before_action
option except
expects an action name, not a controller name. As is, your code is skipping authentication for any action named urls
.
To skip authentication for urls#shortcustom
and urls#shortened
, you need to include
skip_before_action :authenticate_user!, :only => [:shortcustom, :shortened]
in your UrlsController
.
Related Topics
How to Create a Custom Sort Method in Ruby
One or More Params in Model Find Conditions with Ruby on Rails
More Ruby Way of Doing Project Euler #2
Is There a Command Line Framework for Ruby
Gem Ransack Doesn't Return Any Results When Searched with Full Name
Is It Still Advisable to Test Routes in Rails 4 with Minitest
Seed Images in Heroku with Paperclip
Nlp to Classify/Label The Content of a Sentence (Ruby Binding Necesarry)
Error Generating Source Map - Grunt and SASS Configuration
Asynchronously Iterating Over The Response of a Request Using Thin and Sinatra
How to Send an Image on The Web in an Xmpp (Jabber) Message
How to Silence The Call to a Rails Controller's Action All Together
Many to Many Table with an Extra Column in Rails