jjzjj

is_authenticated

全部标签

ruby-on-rails - 如何解决弃用警告 "Method to_hash is deprecated and will be removed in Rails 5.1"

我正在尝试更新到Rails5,我收到以下弃用警告:DEPRECATIONWARNING:Methodto_hashisdeprecatedandwillberemovedinRails5.1,asActionController::Parametersnolongerinheritsfromhash.Usingthisdeprecatedbehaviorexposespotentialsecurityproblems.Ifyoucontinuetousethismethodyoumaybecreatingasecurityvulnerabilityinyourappthatcanbee

ruby-on-rails - 安装 nokogiri : Failed to build gem native extension & libiconv is missing (OSX) 时出错

我尝试克隆thisrepo并运行bundleinstall。捆绑过程失败并抛出此错误:...Installingnokogiri1.6.2.1withnativeextensionsBuildingnokogiriusingpackagedlibraries.Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./Users/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/ruby-r./siteconf20151130-43880-pntnc6.rbextconf.rbBuildi

ruby - 警告 : Can't verify CSRF token authenticity in case of API development

我现在正在使用RubyonRails开发网络API。当Rails应用程序收到没有任何csrftoken的POST请求时,将出现以下错误消息。因为该应用没有View。WARNING:Can'tverifyCSRFtokenauthenticity所以我的问题是在这种情况下如何安全地逃避csrftoken检查?非常感谢您。 最佳答案 你可以通过添加skip_before_filter:verify_authenticity_token到你的Controller。这样,所有传入Controller的请求都会跳过:verify_authen

Ruby 类继承 : What is `<<` (double less than)?

class这是什么为了?我搜索了,但结果只告诉我有关字符串连接的信息... 最佳答案 虽然class是真的是单例类的语法,正如其他人所说,它最常用于在类定义中定义类方法。但是这两种用法是一致的。方法如下。Ruby允许您通过以下方式向任何特定实例添加方法:class这添加了一个方法foo对某个实例,不是对它的类,而是对那个特定实例。(实际上,foo被添加到实例的“单例类”,但这或多或少是一个实现怪癖。)上面的代码执行后,您可以将方法foo发送到某个实例:someinstance.foo=>"Hello."但是您不能将foo发送到同一类

ruby-on-rails - 如何修复 "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0"

我创建了一个Ruby项目,但是在运行bundleupdate和bundleinstall时返回错误:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0它的图像是:http://i.imgur.com/dZMhI11.png?1我的gemfile是:ruby'2.0.0'#ruby-gemset=railstutorial_rails_4_0gem'rails','4.0.0'group:developmentdogem'sqlite3','1.3.8'endgem'sass-rails','4.0.0'gem'uglifier','2

ruby Gemspec 依赖项 : Is possible have a git branch dependency?

在mygem.gemspec中是否可能有一个git分支依赖项?我在想类似下面的事情:gem.add_runtime_dependency'oauth2',:git=>'git@github.com:lgs/oauth2.git'...但它不起作用。 最佳答案 这是不可能的,而且可能永远不会,因为对于RubyGems来说,允许gem开发人员要求用户安装特定的版本控制系统来访问gem是相当严厉的。Gem应该是独立的,具有最少的依赖项,以便人们可以在尽可能广泛的应用程序中使用它们。如果您想为自己的内部项目执行此操作,我的建议是使用Bund

ruby-on-rails - 正确执行 redirect_to :back in Ruby on Rails when referrer is not available

我在使用redirect_to:back时遇到问题。是的,它是推荐人。我经常遇到异常(ActionController::RedirectBackError)"NoHTTP_REFERERwassetintherequesttothisaction,soredirect_to:backcouldnotbecalledsuccessfully.Ifthisisatest,makesuretospecifyrequest.env[\"HTTP_REFERER\"]."我意识到这是由于推荐人不可用造成的。有没有一种方法,例如,可以在访问最后一个页面的每次访问时设置一个session变量,并且

ruby - 执行 rvm 时获取 "Warning! PATH is not properly set up"使用 2.0.0 --default

上面的第一次不起作用,第二次起作用。尝试为任何新的shell窗口将ruby​​版本设置为2.0.0。做$rvmuse2.0.0--default给予Warning!PATHisnotproperlysetup,'/home/durrantm/.rvm/gems/ruby-1.9.3-p125/bin'isnotatfirstplace,usuallythisiscausedbyshellinitializationfiles-checkthemfor'PATH=...'entries,itmightalsohelptore-addRVMtoyourdotfiles:'rvmgetsta

ruby-on-rails - 所有 Ruby 测试都引发 : undefined method `authenticate' for nil:NilClass

我的大部分测试都引发了以下问题,我不明白为什么。所有方法调用都会引发“验证”错误。我检查了代码是否有一个名为“authenticate”的方法,但没有这样的方法。1)Admin::CommentsControllerhandlingGETtoindexissuccessfulFailure/Error:get:indexundefinedmethod`authenticate!'fornil:NilClass#./spec/controllers/admin/comments_controller_spec.rb:9:in`block(3levels)in'124)PostsContr

ruby-on-rails - 如何解决 "ruby installation is missing psych"错误?

我使用rvm安装ruby​​1.9.3。即使安装成功,它也会提示libyaml。现在每次我想安装一个gem(比如rails)时都会出现这个警告:Itseemsyourrubyinstallationismissingpsych(forYAMLoutput).Toeliminatethiswarning,pleaseinstalllibyamlandreinstallyourruby.我使用MacosX10.7(Lion)。 最佳答案 以我为例rvmpkginstalllibyaml和rvmreinstallruby-1.9.3-p1