我有一个拥有用户模型的rails 4应用程序,以及两种类型的用户:贷方和企业。登录时,贷方将被定向到他们的仪表板,向他们显示有关其业务的信息。从仪表板中,他们可以转到他们的“帐户”页面,这是他们可以编辑信息的地方(密码,电子邮件等)。
当用户选择“帐户”时,会显示一条说明:
的设计消息You need to sign in or sign up before continuing.
此时,用户已经过身份验证,仪表板使用@ user.name和视图中的其他调用来访问用户的属性,这些调用需要用户进行身份验证。
我需要弄清楚为什么edit_lender_registration_path不接受当前经过身份验证的用户。
的routes.rb
devise_for :users, skip: :registrations
devise_for :lenders, skip: :sessions, :controllers => {:registrations => "lenders/registrations"}
devise_for :businesses, skip: :sessions, :controllers => {:registrations => "businesses/registrations"}
_sidebar.html.erb
<li class="list-group-item">
<%= link_to edit_lender_registration_path do %>
<i class="fa fa-user"></i> Account
<% end %>
</li>
registrations_controller.rb
class Lenders::RegistrationsController < Devise::RegistrationsController
before_filter :update_sanitized_params
def new
super
flash[:success] = 'An email has been sent to your inbox with a link to activate you account.'
end
def create
super
end
def update
super
end
private
def update_sanitized_params
devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:email, :password, :password_confirmation, :type, :confirmed_at)}
end
end