我正在为我的用户使用设计.我最近安装了rails Active Admin gem,一切都运行得很漂亮.
但是我无法弄清楚如何添加新的管理员用户.我可以看到活动管理员admin_user在数据库中创建了一个用户admin@example.com 的表,我用它来登录界面.
我尝试添加admin_user作为资源,以便我可以单击活动管理界面中的添加管理员用户按钮添加新用户,但这似乎不起作用.
好吧,当有人用一个我想念的简单的东西回答这个问题时,我可能会感到非常愚蠢但是...这里有:
我在rails 3 beta上有一个全新的应用程序,我正在使用设计进行身份验证.我已经完成了所有评论,目前一切都很完美.我已经创建了一个用户角色和一个管理员角色(遵循这些说明:https://github.com/plataformatec/devise/wiki/How-To : -Add- an-Admin- Role)我已将自己注册为第一个用户,但如何注册或创建管理员角色用户?来自设计人员的指示设置管理员角色不可注册但我不确定如果你不能注册你应该如何创建管理员?!
任何帮助,将不胜感激!谢谢!
在我的网络应用程序上使用Rails 4和Devise 3.1.0.我写了一个Cucumber测试来测试用户注册; 从电子邮件中单击"确认我的帐户"链接时失败.
Scenario: User signs up with valid data # features/users/sign_up.feature:9
When I sign up with valid user data # features/step_definitions/user_steps.rb:87
Then I should receive an email # features/step_definitions/email_steps.rb:51
When I open the email # features/step_definitions/email_steps.rb:76
Then I should see the email delivered from "no-reply@mysite.com" # features/step_definitions/email_steps.rb:116
And I should see "You can confirm your account email through the link below:" in the email body # features/step_definitions/email_steps.rb:108
When I follow "Confirm my account" in the email # features/step_definitions/email_steps.rb:178 …Run Code Online (Sandbox Code Playgroud) 我正在使用Rails 5和Devise 3.5.1.
阅读一本关于创建/测试API的好(旧)书,该书使用Devise身份验证.它是在Rails 5之前编写的,所以我选择不使用新的api-only版本.
这是我的测试......
#/spec/controllers/api/v1/users_controller_spec.rb
require 'rails_helper'
describe Api::V1::UsersController, :type => :controller do
before(:each) { request.headers['Accept'] = "application/vnd.marketplace.v1" }
describe "GET #show" do
before(:each) do
@user = FactoryGirl.create :user
get :show, params: {id: @user.id}, format: :json
end
it "returns the information about a reporter on a hash" do
user_response = JSON.parse(response.body, symbolize_names: true)
expect(user_response[:email]).to eql @user.email
end
it { should respond_with 200 }
end
end
Run Code Online (Sandbox Code Playgroud)
这是一个完全出乎意料的RSpec错误
Devise::MissingWarden:
Devise could not find the `Warden::Proxy` instance on your request environment. …Run Code Online (Sandbox Code Playgroud) 我的会话设置在1-3小时不使用后设置超时(不确定确切多长时间).我该怎么调整呢?
我查看了文档,似乎找不到这个设置.
谢谢
问题:简而言之,当我尝试向我的应用程序安装注销链接时,它无法正常工作.这里有我认为放在这里的背景(如果你想要别的什么,请戳我)......
我在haml视图中得到了这个:
= link_to("Logout", destroy_user_session_path, :method => :delete)
Run Code Online (Sandbox Code Playgroud)
它在视图中生成:
<a href="/users/sign_out" data-method="delete" rel="nofollow">Logout</a>
Run Code Online (Sandbox Code Playgroud)
我在我的config/initializers/devise.rb中验证了我的设置没有注释并且正确:
config.sign_out_via = :delete
Run Code Online (Sandbox Code Playgroud)
我验证了以下路线:
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
Run Code Online (Sandbox Code Playgroud)
我的routes.rb中也有这点诡计,我怀疑这与我的问题有关:
devise_for :users, :controllers => {:sessions => "devise/sessions", :registrations => "users"}
resources :users
Run Code Online (Sandbox Code Playgroud)
最后一点是因为我想在自己的控制器中管理(编辑,创建和删除)用户.
我得到的错误信息如下:
ActiveRecord::RecordNotFound in UsersController#show
Couldn't find User with ID=sign_out
Rails.root: /home/jaydel/projects/mbsquared-projects/Wilson-Goldrick
app/controllers/users_controller.rb:16:in `show'
Run Code Online (Sandbox Code Playgroud)
在我的服务器日志中,我看到了这个请求:
Started GET "/users/sign_out" for 127.0.0.1 at 2011-08-04 13:08:51 -0500
Processing by UsersController#show as HTML
Parameters: {"id"=>"sign_out"}
Run Code Online (Sandbox Code Playgroud)
有人有主意吗?
我一直在Rails 2.3中使用Authlogic,但现在我正在使用Rails 3,我想我可能会试用一种新的身份验证解决方案.
Devise与Authlogic相比如何?他们有什么不同?
我对设计gem配置设置感到困惑:
# The time the user will be remembered without asking for credentials again.
config.remember_for = 2.weeks
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again.
config.timeout_in = 10.minutes
Run Code Online (Sandbox Code Playgroud)
我想让用户选中"记住我"复选框(即让我保持登录状态),但默认会话超时为10分钟.10分钟后,它要求我再次登录,即使我点击了"记住我".如果这是真的那么remember_for真的没有意义.显然我在这里遗漏了一些东西.
在我的特定用例的应用程序中,我创建了一个新用户(以编程方式设置密码)并向他们发送确认电子邮件.
我希望他们能够在确认后立即更改密码(无需输入系统生成的密码,我不想发送它们)
实际上我想
1)系统使用生成的密码创建一个新的用户帐户.
2)系统发送确认电子邮件.
3)用户点击确认并被重定向以输入他们的密码(有效地将他们发送到如下的URL)
<a href="http://localhost:3000/users/password/edit?reset_password_token=v5Q3oQGbsyqAUUxyqLtb">Change my password</a>
Run Code Online (Sandbox Code Playgroud)
任何帮助/指针都会很棒.
最新版本的Devise没有:默认情况下启用确认.我已经将相应的列添加到用户模型,但找不到任何如何启用的代码示例:确认.
我在哪里可以找到一个好的示例或启用它需要什么代码?