I need help with devise and the option to use multiple models.
At the moment i got a User model and a Client model which is inside a namespace:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :registerable, :rememberable, :trackable, :validatable
end
class Test::Client < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
As you can see, i included devise in both models. Like its in the doc..
So have a look at my routes:
devise_for :users, controllers: {passwords: 'passwords',
sessions: 'sessions'}
devise_for :clients, class_name: 'Test::Client', controllers: {sessions: 'test/sessions'}
My problem now is, that when i create a login form for my Client model:
<%= form_for(resource, as: resource_name, url: client_session_path(resource_name), html: {class: ''}) do |f| %>
<% end %>
it has following url: /clients/sign_in.client
What is this .client? It drives me crazy. When you need more informations let me know..
EDIT 1:
I edited my model structure now.
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :recoverable, :registerable, :rememberable, :trackable, :validatable
end
class Test::Client < User
# some Client only functions
end
So the login as a normal User works. But the Client login still doesn't. In my view i did this:
<%= form_for(Test::Client.new, as: :client, url: session_path(:client)
When i enter my credentials i get redirected to "/users/sign_in" but nothing else happend. In my log i got a filter entry:
Filter chain halted as :require_no_authentication rendered or redirected