I have Devise 4.2.1 and Rails 5.0.1. I'm trying to use Devise sign_in
in a controller other than registrations
. There were a bunch of methods that weren't defined, so I had to add them as helpers:
module ApplicationHelper
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
def build_resource(hash=nil)
self.resource = resource_class.new_with_session(hash || {}, session)
# ^the source of the error^
end
def resource_class
devise_mapping.to
end
end
But now I'm getting the following error:
NoMethodError in Static#show
undefined method 'resource=' for (class)
I don't have "resource=" written anywhere in my code, certainly not on the line the error points to (marked above). Where is my server getting that error from?
Also, I think I'm just using the standard sign_in code:
<%
build_resource({})
set_minimum_password_length
yield resource if block_given?
respond_with self.resource
%>
<% form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
...