Tag: 设计

Ruby on Rails Omniauth facebook不会返回电子邮件

我一直在努力设置我的Omniauth for facebook我不知道我做错了什么。 我无法收到用户的电子邮件。 返回的哈希只包含“name”和“uid”,甚至不包含“first_name”和“last_name” devise.rb: config.omniauth :facebook, “KEY”, “SECRET” omn​​iauth_callbacks_controller.rb: class OmniauthCallbacksController < Devise::OmniauthCallbacksController def facebook logger.info request.env["omniauth.auth"] @user = User.from_omniauth(request.env["omniauth.auth"]) sign_in_and_redirect @user end end user.rb: class User [:facebook] has_many :authentications def self.from_omniauth(auth) logger.info auth user = where(email: auth.info.email).first if(user != nil) user.authentications.where(provider: auth.provider, uid: auth.uid).first_or_create do |l| user.authentications.create!(user_id: user.id, provider: auth.provider, uid: auth.uid) […]

表单提交后设计覆盖重定向

如何配置我的Rails应用程序,以便在创建新用户的表单(通过设计)后,我重定向到我自己想要的页面? 谢谢

自定义设计会话控制器的RSpec测试因AbstractController :: ActionNotFound失败

我目前正在尝试使用rspec测试自定义Devise会话控制器。 我的控制器看起来像这样: class SessionsController < Devise::SessionsController def create #valid email? if !(params[:email] =~ /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/) set_flash_message :notice, "Please enter a valid e-mail address!" end super end end 我的RSpec控制器测试是这样的: require ‘spec_helper’ require ‘devise/test_helpers’ describe SessionsController do it “should put a warning on invalid mail address login attempt” do post :create, :user => {:email => ‘invalidEmailAddress’} response.should contain […]

如何添加用户名字段来设计gem?

这是我试过的, rails g migration add_username_to_hrs bundle exec rake db:migrate 添加了attr_accessible:username 重启服务器 我的add_username_to_hr.rb class AddUsernameToAuthorize < ActiveRecord::Migration def change add_column :authorizes, :username, :string end end 错误 #的未定义方法`username’ 问题 :如何在我的设计gem中添加用户名字段?

在Rails 3中使用用户名绘制路径w / devise

鉴于使用设计管理的用户与“事物”之间的一对多关系,我的目标是绘制如下的宁静路线: http://host/username http://host/username/things http://host/username/things/1 … 我知道Rails路由中的嵌套资源 ,但我无法弄清楚如何将它应用于通过设计创建和管理的通用用户模型。

Ruby on Rails:没有将Array隐式转换为String(DEVISE)

我最近从10.7升级到OSX Mavericks 10.9,从那时起它给我带来了很多麻烦。 我升级了Xcode,命令行工具,重新安装了自制软件和rvm,最后让rails工作(我花了5个小时让rmagick再次工作)。 但是,现在当我尝试从我的localhost访问我的应用程序时,我收到此错误 no implicit conversion of Array into String 这是rails日志: Started GET “/” for 127.0.0.1 at 2014-05-05 02:20:00 -0700 Processing by AccountsController#dashboard as HTML Completed 500 Internal Server Error in 0.3ms TypeError (no implicit conversion of Array into String): app/controllers/application_controller.rb:26:in `check_correct_subdomain’ Rendered /Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms) Rendered /Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) Rendered /Users/kibaek/.rvm/gems/ruby-2.1.0@onvard/gems/actionpack-3.2.16/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (7.1ms) […]

在filter之前进行设计,以防止访问“new_user_registration_path”,除非用户已登录

我在我的rails应用程序中使用Devise。 我的用户模型是可注册的,这意味着任何人都可以转到/ users / sign_up并创建一个新帐户。 是否可以保护此路由,以便只有signed_in用户才能创建新帐户?

允许用户在Devise中添加新用户,并保持自己登录

我使用Ruby On Rails与Devise,Rails 4.1.0.rc1,Ruby 2.1.0p0,devise-3.2.4 我按照Rails Cast Episode#209的教程来安装和使用设计。 我可以登录并注销并注册新用户。 我扩展了我的用户模型,以包含生日,名字和姓氏等不变信息。 在这篇博客文章之后,我添加了一个用户控制器和视图,以便添加其他function,例如我没有用设计看到的所有用户的列表。 https://github.com/danweller18/devise/wiki/Allow-Users-to-View-Profile-and-List-All-Users 我还回顾了关于堆栈溢出的这些问题: 允许管理员使用Devise添加用户 如何在Devise中自定义控制器以进行注册? Ruby on Rails:自定义设计注册控制器,请求创建操作 从今年3月1日开始,我是ruby on rails的新手,并参加了Mike&Nicole Clarks Rails 1&Rails 2在线课程。 我想要做的是允许用户添加新用户。 最终,此function将是添加客户端的管理员或经理。 然后,客户端应该能够使用创建的凭据登录。 发生的事情是我可以登录,通过new_user_path和用户视图添加新的“用户”(而不是设计视图),但是当我提交它时,我将以新用户身份登录。 以前的用户不是持久的。 我通过用户视图和控制器操作执行所有这些操作,因为我不想实际“注册”或使用这些操作登录和注销,只需在用户表中创建新记录,然后就可以登录到他们的拥有。 任何帮助表示赞赏。 这是我的用户控制器: class UsersController < ApplicationController def index @users = User.all end def show @user = User.find_by_id(params[:id]) end def new @user = User.new end […]

Rails设计会话控制器

在设计中,许多教授如何完成某些事情的页面需要编辑会话控制器。 我使用这个https://github.com/fortuity/rails3-subdomain-devise/wiki/Tutorial-(Walkthrough)设置了设备。它没有重新制作会话控制器。 我怎么做一个。 (如果真的很容易对不起,请给我几个简单的步骤)

测试使用Devise和RSpec的视图

我想在添加Devise的user_signed_in?之后获得之前传递的rspec“视图规范” user_signed_in? 有问题的视图模板的方法。 模板看起来像这样: Welcome back. Please sign in. 传递的视图规范看起来像这样: require “spec_helper” describe “home/index.html.erb” do it “asks you to sign in if you are not signed in” do render rendered.should have_content(‘Please sign in.’) end end 添加对user_signed_in?的调用后产生的错误user_signed_in? 是: 1) home/index.html.erb asks you to sign in if you are not signed in Failure/Error: render ActionView::Template::Error: undefined method […]