草庐IT

devise_error_messages

全部标签

ruby-on-rails - 带有 Devise 的 JSON Web token

我希望这不算是一个自以为是的问题。我只需要指出正确的方向。我正在修改Devisegem以完全使用JSON。到目前为止,我在注册、确认、重新确认、锁定方面没有遇到任何问题。然而,在使用登录时,我深入挖掘并了解到默认的Devise登录策略使用Warden,因为它与session和Rack身份验证。我理解JWT本身包含所有信息,不需要session。因此,如果我剥离所有内容的默认Devise策略并简单地在成功时返回一个JWT并在错误时返回一个错误,这是否是正确的方法?我错过了什么吗? 最佳答案 为了将JWT与设计一起使用,我建议不要使用猴

ruby - "Error validating client secret."404 与 Facebook Oauth 和 ruby

我正在尝试使用warden为应用程序实现facebook身份验证,在用户允许facebook身份验证并使用token重定向到我的应用程序回调后,我在使用api时得到400。我的典狱长策略是这样的:classFacebook'https://graph.facebook.com'enddefparams@params||=Rack::Utils.parse_query(request.query_string)enddefauthorize_urlclient.web_server.authorize_url:redirect_uri=>request.url,:scope=>'emai

ruby-on-rails - ActionController::InvalidAuthenticityToken Rails 5/Devise/Audited/PaperTrail gem

背景详情我正在使用Devise进行身份验证以登录到Rails5应用程序。每当我捆绑Audited或PaperTrailgem时,当我尝试#create一个新session时(通过登录表单-/users/sign_in),我收到以下错误:ActionController::InvalidAuthenticityToken环境详情ruby2.3.1gem:rails5.0.2设计=>4.2.1paper_trail=>7.0.1重现步骤:创建Rails5应用程序添加Devisegem添加经过审计或纸质记录的gem尝试登录 最佳答案 事实

ruby-on-rails - 国际化 : error message localization for particular model

我可以为每个验证本地化错误消息,但我如何为特定模型创建错误。普通语言环境看起来像这样:en:mongoid:errors:messages:taken:"Itisalreadytaken"但我想为user模型更改消息:en:mongoid:errors:messages:taken:"Itisalreadytaken"user:taken:"Itisalreadytaken.%{link_to'Rememberpassword',reset_password_path'}" 最佳答案 试试这个:en:mongoid:errors:m

ruby-on-rails - 为什么 PG::UniqueViolation: ERROR: duplicate key value violates unique constraint?

我有一个模型Post,每次创建帖子时,我都希望同时创建一个新的Moderation实例。所以在post.rb中我使用回调after_save:create_moderation然后写一个私有(private)方法:...includeReportableafter_save:create_moderationprivatedefcreate_moderationself.create_moderation!(blog:Blog.first)end但是在创建提案时出现此错误:PG::UniqueViolation:ERROR:duplicatekeyvalueviolatesunique

ruby - 在没有 rvm 或 rbenv 的情况下编译 Ruby 2.0 错误, `readline.c:1886:26: error: ' Function' undeclared (first use in this function)`

我想安装gitlab,不推荐使用任何ruby版本管理器。但是这是我的操作系统Linuxdqa-dev3.13.0-24-generic#46-UbuntuSMPThuApr1019:08:14UTC2014i686i686i686GNU/Linuxlinkingshared-objectpsych.soinstallingdefaultpsychlibrariesmake[2]:Leavingdirectory`/home/poc/ruby-2.0.0-p451/ext/psych'make[2]:Enteringdirectory`/home/poc/ruby-2.0.0-p451/

ruby-on-rails - Rails 3 和加密字符串 Gem - 获取 OpenSSL::Cipher::CipherError: bad decrypt error

我正在使用rails3.2、Ruby1.9.3和encrypted_stringsgem,尝试以下操作:"wC6234sdf234234cCY1Lag==\n".decrypt(:symmetric,:key=>"mykeynottelling")我收到这个错误:OpenSSL::Cipher::CipherError:baddecrypt然而,这不会发生在Ruby1.8.7中。我对此有点迷茫,有人知道是什么原因造成的吗?更新1:如果我在ruby​​1.8.7中加密一个字符串:"password".encrypt(:symmetric,:key=>"www.buyandsell.ie"

ruby-on-rails - 如何修复 PG::DuplicatePstatement: ERROR?

我想知道如何防止此类错误。到目前为止,我尝试通过AWSOpsworks的数据库配置禁用准备好的语句:例如:数据库配置},"deploy":{"app_name":{"database":{"adapter":"postgresql","prepared_statements":false,"username":"username","database":"db_name_production","host":"cool_host.com","password":"easy"},错误日志PG::DuplicatePstatement:ERROR:preparedstatement"a6"

ruby - better_errors 要求 Ruby 版本 >= 2.0.0

Bundle无法安装better_errors。Gem::InstallError:better_errorsrequiresRubyversion>=2.0.0.Anerroroccurredwhileinstallingbetter_errors(2.0.0),andBundlercannotcontinue.Makesurethat`geminstallbetter_errors-v'2.0.0'`succeedsbeforebundling.但是geminstallbetter_errors工作正常。ruby--version表示ruby2.0.0p353(2013-11-22

ruby-on-rails - 在 Devise on Rails 中使用单独的身份验证模型

我有一个简单的解决方案,我自己使用以下对象:Account(有token字段,认证时返回并用于API调用)身份验证(具有auth_type/auth_id和对帐户的引用)我有一个单独的身份验证模型,可以连接多种登录方式(设备UUID、电子邮件/密码、twitter、facebook等)。但似乎在Devise的所有示例中,您都在User(Account)模型上使用它。那不是不够灵活吗?例如,OmniAuth模块在User模型上存储提供者和ID,如果您希望能够从Twitter和Facebook登录,会发生什么情况?只有一个提供者有空间吗?我应该在我的Account模型还是Authentic