简体   繁体   English

使用Devise在Heroku上运行Rails应用

[英]Running a Rails app on Heroku with Devise

I am trying to setup a Rails app on Heroku using PG, and also using devise and oauth to interact with the Yahoo Sports api. 我正在尝试使用PG在Heroku上设置Rails应用,还尝试使用devise和oauth与Yahoo Sports api进行交互。

I am running into an issue where when the users goes to authenticate the Heroku logs are telling me: 我遇到了一个问题,当用户去认证Heroku日志时告诉我:

ActiveRecord::StatementInvalid (PG::Error: ERROR:  value too long for type character varying(255)

So after reading this Stack Overflow post PostgreSQL string(255) limit - Rails, Ruby and Heroku , I tried changing the token to text from string since that seemed to be the longest thing that may be causing the over 255 limit. 因此,在阅读了PostgreSQL的 Stack Overflow的string(255)限制-Rails,Ruby和Heroku之后 ,我尝试将令牌从字符串更改为文本,因为这似乎是最长的事情,可能会导致超过255的限制。 My migration looked like this: 我的迁移看起来像这样:

class AddAccessTokenToAuthentications < ActiveRecord::Migration
  def change
    add_column :authentications, :token, :text, :limit => nil
    add_column :authentications, :secret, :string
  end
 end

However for some reason it seems to be changing everything to text. 但是由于某种原因,它似乎正在将所有内容更改为文本。 When I look at my schema after migrating it shows: 迁移后查看架构时,它显示:

create_table "authentications", :force => true do |t|
  t.integer  "user_id"
  t.text     "provider",   :limit => 255
  t.text     "uid",        :limit => 255
  t.datetime "created_at",                :null => false
  t.datetime "updated_at",                :null => false
  t.text     "token",      :limit => 255
  t.text     "secret",     :limit => 255
 end

When I push to Heroku and try to migrate on Heroku I am getting this error: 当我推送到Heroku并尝试在Heroku上迁移时,出现此错误:

   -- create_table("authentications", {:force=>true})
     NOTICE:  CREATE TABLE will create implicit sequence "authentications_id_seq" for serial column "authentications.id"
   rake aborted!
   PG::Error: ERROR:  type modifier is not allowed for type "text"
   LINE 1: ...serial primary key, "user_id" integer, "provider" text(255),...
   : CREATE TABLE "authentications" ("id" serial primary key, "user_id" integer, "provider" text(255), "uid" text(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "token" text(255), "secret" text(255))

I am not sure how to resolve this or what I should be looking into. 我不确定如何解决这个问题或者我应该研究什么。

PG::Error: ERROR:  type modifier is not allowed for type "text"

means you can't use :limit 表示您不能使用:limit

What you can do is either: 您可以执行以下任一操作:

t.text "provider" # = varchar(max)

or 要么

t.string "provider",   :limit => 2147483647 # for max limit based on your db

Your text fields are unable to have a limit on them. 您的text字段不能有限制。 Perhaps you meant to use string instead? 也许您打算使用string代替?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM