草庐IT

ruby-on-rails - 找不到路径 "/sessions/user"的设计映射设计登录错误

最近几天很郁闷。我有一个安装了Devise的Rails应用程序,我在其中生成了一个新的用户模型,并且还生成了DeviseView。当我在填写电子邮件和密码字段后单击“登录”并尝试以现有用户身份登录时,会发生这种情况:AbstractController::ActionNotFound-Couldnotfinddevisemappingforpath"/sessions/user".Thismayhappenfortworeasons:1)Youforgottowrapyourrouteinsidethescopeblock.Forexample:devise_scope:userdog

ruby-on-rails - Rails 设计 : user_signed_in? 不工作

我的观点是:但是当以用户身份登录时:我仍然可以看到链接:为什么助手不工作? 最佳答案 您是否在Controller中使用了devise的beforeaction?before_action:authenticate_user! 关于ruby-on-rails-Rails设计:user_signed_in?不工作,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6003883/

ruby-on-rails - rails : Your user account isn't allowed to install to the system RubyGems

我正在运行命令bundleinstall在项目文件夹中。在某些项目文件夹中,它会产生错误,而在其他项目文件夹中,它不会产生错误。错误是:Youruseraccountisn'tallowedtoinstalltothesystemRubyGems我知道这可以通过遵循推荐的建议来解决:bundleinstall--pathvendor/bundle我的问题是为什么行为不一致? 最佳答案 在我的例子中,我按照错误消息的建议解决了问题:Youruseraccountisn'tallowedtoinstalltothesystemRubyG

ruby-on-rails - 未定义方法 `accept' 为 nil :NilClass on rake db:migrate

使用ruby​​-1.9.2和rails3.2.1。mysql2的版本是0.2.7。运行rakedb:migrate时出现错误:“nil:NilClass的未定义方法‘accept’:”跟踪包括:gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in`to_sql' 最佳答案 从以下位置更改您的Gemfile:gem'activerecord-mysql2-adapter'到:gem'mysq

ruby - 执行 rake db :migrate on Heroku 时出错

做的时候heroku运行rakedb:migrate所有迁移都已执行,最后我总是收到以下消息:/app/vendor/bundle/ruby/1.9.1/bin/rake:没有这样的文件或目录-pg_dump-i-s-x-O-f/app/db/structure.sqldan79p98fykovu我无法在Heroku上将pg_dump添加到PATH。如何处理? 最佳答案 问题在于,迁移完成后,rails会尝试转储新的structure.sql,但由于pg_dump不存在而失败。为已部署的应用程序生成新的structure.sql毫无

ruby-on-rails - 当我运行 `bundle exec rake test:prepare` 时它出错了,但是 `bundle exec rake db:test:prepare` 运行正常但有警告。这是怎么回事?

所以根据thislink一个是快捷方式包装器(所以我猜它们是一样的)。当我运行bundleexecrakedb:test:prepare时,我得到了这个错误:Don'tknowhowtobuildtask'test:prepare'/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in`eval'/Users/aj/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin/ruby_executable_hoo

ruby-on-rails - 如何在 rspec 功能测试中访问(设计)current_user?

在设计文档中,他们提供了有关在测试Controller时如何访问current_user的提示:https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29但是,在进行功能测试时呢?我正在尝试测试我的一个Controller的创建方法,并且在该Controller中使用了current_user变量。问题是devise中建议的宏使用了@request变量,并且对于功能规范来说它是nil。什么是解决方法?编辑:这是我目前的规范:feature

ruby-on-rails - 迁移正在等待;运行 'bin/rake db:migrate RAILS_ENV=development' 来解决这个问题[无法继续]

我似乎有一个关于RubyonRails迁移过程的循环问题。我正在关注介绍文章,我已经到了需要创建我的第一个表的地步。我已经运行了以下,[tims@web2working_ror]#railsgeneratemodelHomepagefirst_name:stringlast_name:stringemail:stringmessage:textinvokeactive_recordcreatedb/migrate/20131119203948_create_homepages.rbcreateapp/models/homepage.rbinvoketest_unitcreatetest

ruby-on-rails - 运行 rake db :migrate 时,Rails 创建迁移以将列添加到表中会导致错误

我创建了一个名为“用户”的模型,我创建了一个新的迁移以将一些列添加到用户表中。现在,当我运行rakedb:migrate时,我得到以下b/c错误,它正在尝试再次创建用户表$rakedb:migrate==DeviseCreateUsers:migrating==============================================--create_table(:users)rakeaborted!Anerrorhasoccurred,alllatermigrationscanceled:Mysql::Error:Table'users'alreadyexists:CR

ruby Mechanize : user agents?

Mechanize中有多少用户代理?是否有所有用户代理选项的便捷列表? 最佳答案 是的。看https://github.com/sparklemotion/mechanize/blob/master/lib/mechanize.rb#L115:AGENT_ALIASES={'WindowsIE6'=>'Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.1)','WindowsIE7'=>'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;.NETCLR1.1.4