Tag: 设计

设计:将“电子邮件”替换为替代登录

我尝试使用Sublime的“替换所有文件”function在整个应用程序中用accountnumber替换email 。 我重置并重新迁移了数据库,但是,在注册时我仍然收到以下错误: undefined method `email’ for # 然后是以下参数 {“utf8″=>”✓”, “authenticity_token”=>”2qqA7dx99hx+VqkZGDmySNJd+2Fzxuanegy1ysrpD30=”, “account”=>{“accountnumber”=>”1307”, “password”=>”[FILTERED]”, “password_confirmation”=>”[FILTERED]”}, “commit”=>”Sign up”} 以前有人有这个困难吗?

如何检查用户是否使用omniauth登录

我有一个应用程序在设计和omniauth运行用户注册。 但是当有人使用omniauth登录facebook时,我想为该用户显示一些额外的信息。 但是,我找不到一种方法来确定该用户是否已使用Facebook登录。 我相信它与devise_helper(user_signed_in?)有关,但我不知道如何在omniauth中使用它。 user.rb def self.find_for_facebook_oauth(auth) where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user| user.name = auth.info.name user.provider = auth.provider user.uid = auth.uid user.email = auth.info.email user.password = Devise.friendly_token[0,20] user.username = auth.info.email user.token = auth.credentials.token user.save! end end devise.rb config.omniauth :facebook, ENV[“APP_ID”], ENV[“APP_SECRET”], {:scope => ’email, offline_access’, :client_options => {:ssl => {:ca_file => ‘/usr/lib/ssl/certs/ca-certificates.crt’}}} 码

如何让ldap与rails中的设计一起工作?

我正在使用设计,我尝试使用ldap,我的所有尝试都导致失败。 我已经关注了http://vimeo.com/13105005 ,我正在寻求帮助。 Started POST “/users/sign_in” for 127.0.0.1 at 2013-04-16 18:01:54 +0530 Processing by Devise::SessionsController#create as HTML Parameters: {“utf8″=>”✓”, “authenticity_token”=>”N7Xkqk8nHWqK4tgiCxyX4wFccSO8ozhy+nxXqS19arA=”, “user”=>{“email”=>”logesh@gmail.com”, “password”=>”[FILTERED]”, “remember_me”=>”0”}, “commit”=>”Sign in”} WARNING: Can’t verify CSRF token authenticity User Load (0.6ms) SELECT “users”.* FROM “users” WHERE “users”.”email” = ‘logesh@gmail.com’ LIMIT 1 LDAP: LDAP dn lookup: cn=logesh@gmail.com LDAP: LDAP search for login: cn=logesh@gmail.com […]

具有多个Devise模型的Actioncable身份validation

我目前正在实现两个Devise模型之间的聊天。 Client和Professionnel 。 目前工作正常,但我只有一个渠道:每个客户或专业人员都会收到来自所有客户和所有专业人士的所有消息。 显示很好,但是观看他们的AJAX流的人可以看到每个不适合他们的私人消息。 根据这个主题http://www.thegreatcodeadventure.com/rails-5-action-cable-with-multiple-chatroom-subscriptions/这被称为单一责任原则 所以我试图创建“子流”,以便向正确的用户广播。 我的第一步是使用Devise进行authing。 我正在使用经典: module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.email end protected def find_verified_user if verified_user = env['warden'].user verified_user else reject_unauthorized_connection end end end end 这就是出现问题的地方:当客户端登录时,Actioncable不会创建连接: Started GET “/cable” for 127.0.0.1 at 2018-04-16 22:30:28 +0200 Started GET “/cable/” [WebSocket] for […]

Rails Postgres架构问题 – 以下架构之一无效:“test”“public”

我已经高低搜索了这个答案,但我很短暂。 我正在尝试使用基于Postgres模式的Rails 4,Devise和Apartment构建多租户应用程序。 对于我当地的Postgres服务器,我决定使用PostgresApp。 我按照Go Rails多租户指南进行操作,当这个错误开始出现时,我有了这个设置(每个租户一个用户)。 当我试图为Devise安装Invitable扩展时,昨天开始在本地显示,我似乎找不到任何关于发生了什么的线索。 以下是我如何得到具体错误: michael$ rake environment db:drop michael$ rake db:create michael$ rake db:migrate == 20160908204559 DeviseCreateUsers: migrating ================================ — create_table(:users) -> 0.0091s — add_index(:users, :email, {:unique=>true}) -> 0.0032s — add_index(:users, :reset_password_token, {:unique=>true}) -> 0.0031s — add_index(:users, :confirmation_token, {:unique=>true}) -> 0.0032s — add_index(:users, :unlock_token, {:unique=>true}) -> 0.0029s == 20160908204559 DeviseCreateUsers: migrated […]

devise.rb – 调用send_reset_password_instructions时的Net :: SMTPSyntaxError

我在调用send_reset_password_instructions({:email => ‘my@email.com’})设计助手时收到Net::SMTPSyntaxError 501 Syntax Error 。 我使用Ruby 1.9.3,Rails 3.2.19并设计2.2.8。 调用函数的片段: class UserController def reset User.send_reset_password_instructions(hash_params) # {:email => ‘my@email.com’} # … more code down here … end end User类激活了以下设计模块: class User … devise :registerable, :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable ## Devise Fields ## Database authenticatable field :email, :type => String, :null => false […]

每次都使用设计GETing而不是在Rails 4中进行POST

所以这似乎是一个非常普遍的问题。 我已经梳理了github上的问题跟踪器以及Stackoverflow,但仍未找到解决方案 – 更改config.sign_out_via = :delete to config.sign_out_via = :get – 这显然是非常糟糕的做法。 我的问题是,无论我尝试什么,客户端都会发送一个get请求而不是指定的delete或post 。 在我看来 :delete %> 耙路线给出 Anchor$ rake routes Prefix Verb URI Pattern Controller#Action root GET / home#index new_user_session GET /login(.:format) devise/sessions#new user_session POST /login(.:format) devise/sessions#create destroy_user_session DELETE /logout(.:format) devise/sessions#destroy user_password POST /password(.:format) devise/passwords#create new_user_password GET /password/new(.:format) devise/passwords#new edit_user_password GET /password/edit(.:format) devise/passwords#edit PATCH […]

尝试使用设备注册用户时的ActiveRecord :: AssociationTypeMismatch

我正在尝试使用devise gem在注册过程中附加嵌套字段。 我想在一个请求中创建用户创建后属于User的video。 表单从registrations_controller.rb发送post to create方法,并在sign_up参数处失败 new.html.erb <input name="authenticity_token" type="hidden" value="”/> ( characters minimum) title desc registrations_controller.rb def create super end private def sign_up_params params.require(:user).permit(:email, :password, password_confirmation, videos: [:title, desc]) end 用户模型 class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, […]

Rails 4设计 – 如果未经过身份validation,则重定向用户

有authenticate_user! 在comments_controller中。 before_action :authenticate_user! 当用户点击创建评论时,他们现在会重定向到users / sign_in页面。 但是,我想将它们重定向到root_url并发出通知登录。主页上有登录按钮(FB和G +)。 我看过这个 ,但是当我实现它时,我只得到一个具有相同URL的黑色页面和已完成401未授权 。

如何在使用Devise时构建经过身份validation的路由?

在我的问题中如何在用户未登录rails时拥有根视图? max回答我们可以使用authenticated来使路由仅在有人通过身份validation时可用。 我正在探讨如何构建这个: Rails.application.routes.draw do devise_for :users authenticated :user do # when authenticated allow all action on student resources :subjects do resources :students end end # when not only allow read on student resources :subjects do resources :students, only: [:get] end root “home#index” end 问题是我不想允许任何未经validation的操作:subjects如何阻止?