我试图在前面和后面分开登录视图,我正在创建devise模型和admin模型继承用户。
../model/user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable
我的应用程序中有两个用于sign_in的模型。我也没有为devise生成任何控制器,都是内置的。我的ApplicationController是这样的:
def after_sign_in_path_for(resource)
case resource
when User then request.referrer
when Admin::Admin then :admin_mainpage
end
end
def after_sign_up_path_for(resource)
root_path
end
def a
我在尝试访问<%= link_to(‘编辑注册’,edit_user_registration_path) %>时遇到以下错误。
Routing Error
No route matches {:action=>"edit", :controller=>"profiles"}
Try running rake routes for more information on available routes.
routes.rb
xyz::Application.routes.draw do
root :to => "home
我的注册路径是users/ sign _ up /speed1等。但是,如果有一个设计错误,比如密码不匹配,它会将用户重定向到“/users”路径。功能,它应该重定向回同一页,并让用户重新输入新密码。有什么最新进展吗? class RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
super
end
def update
super
end
def speed1
build_resource
我正在使用Design3.1.1,并试图在用户注册后将用户重定向到页面中的标志。按照中的指示,我使用以下内容重写了RegistrationsController:
class RegistrationsController < Devise::RegistrationsController
protected
def after_inactive_sign_up_path_for(resource)
'/users/sign_in'
end
end
按照指示,我还向routes.rb添加了以下行
devise_for :users, controll
我访问了localhost/3000/login_users/sign_up并注册了一个用户。之后,我访问了localhost/3000/login_users/sign_in。但是,它总是被重定向到localhost:3000。
我会发routes.rb的。
为什么会这样呢?
Rails.application.routes.draw do
devise_for :login_users
# For details on the DSL available within this file,
# see http://guides.rubyonrails.org/routing.
请在最下面阅读,我编辑了我的帖子,我仍然需要帮助。
问候
我正在使用devise来验证用户和管理员的身份( admin : true)。作为管理员,我想访问用户配置文件的页面,但我总是访问我自己的配置文件(作为current_user)。我不知道怎么做..。
用户也可以看到其他用户配置文件。
谢谢你的帮助
用户/index.html.slm
.container
h1 All the users
.row
table.board
thead
tr
th First Name
th Last Name
th Emai
我有一些麻烦,弄清楚如何自动创建一个用户配置文件对象,一旦用户已经注册使用的设计。我的profile对象已经退出,现在需要将空的Profile.new对象添加到用户对象中。以下代码来自registrations_controller.rb
protected
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
devise_parameter_sanitizer.for(:sign_up) << :profile_id
我决定制作一个RegistrationsController,这样我就可以在注册到特定页面时将用户重定向。唯一的问题是用户甚至没有被创建,因为我得到了错误:
Started POST "/users" for 127.0.0.1 at 2012-06-12 14:01:22 -0400
AbstractController::ActionNotFound (The action 'create' could not be found for R
egistrationsController):
我的路线和控制员:
devise_for :users, :con
我试着用谷歌找到解决方案,但是找不到.
是唯一的问题。它只有一个答案,被接受了,但对我不起作用.这是我的代码:
class RegistrationsController < Devise::RegistrationsController
before_filter :authenticate_user!
def new
puts "Method new was called"
super
end
end
当我不在localhost:3000/sign_up登录时,页面将正常显示并打印Method new was called。如果我还没