小编roc*_*555的帖子

在rails中使find_by返回多个结果

我试图返回用户创建的所有组.所有组都与用户ID相关联.当我运行find_by查询时,它只返回第一个结果.有没有办法让它返回多个?提前致谢

ruby postgresql ruby-on-rails

12
推荐指数
2
解决办法
7873
查看次数

DB上的错误:迁移"未初始化的常量DeviseCreateUsers"

我正在尝试在Heroku上运行rake db:migrate命令,我遇到了这个问题.

    uninitialized constant DeviseCreateUsers
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `constantize'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:538:in `load_migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:533:in `migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:719:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/migration.rb:551:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

以下是我的Devise创建用户方法的全文,该方法似乎导致了此问题.

class AddDeviseToCustomers < ActiveRecord::Migration
def self.up
change_table(:customers) do |t|
  ## Database authenticatable
  t.string :email,              :null => false, :default => ""
  t.string …
Run Code Online (Sandbox Code Playgroud)

ruby postgresql ruby-on-rails heroku

8
推荐指数
1
解决办法
6110
查看次数

cname重定向导致heroku中的网络钓鱼警告

我按照此链接https://devcenter.heroku.com/articles/custom-domains中的说明更改了我的CNAME记录.重定向本身有效,问题出在Chrome中(我假设其他浏览器)它给了我一个网络钓鱼警报.

这可能不是您要找的网站!

您试图访问app.grewpr.com,但实际上您已经到达服务器,我将自己标识为*.herokuapp.com.这可能是由服务器上的配置错误或更严重的问题引起的.您网络上的攻击者可能会试图让您访问app.grewpr.com的假(且可能有害)版本.

您不应该继续,特别是如果您之前从未见过此网站的此警告.

我该如何解决这个错误?它还通过https锁定了一条红线.

dns ruby-on-rails heroku

5
推荐指数
1
解决办法
1401
查看次数

标签 统计

ruby-on-rails ×3

heroku ×2

postgresql ×2

ruby ×2

dns ×1