У меня есть приложение rails, где пользователи могут писать кавычки, а другим пользователям они могут нравиться, просто так, все работает превосходно локально, но когда я вставил свой код в свое приложение heroku, оно показывает необычную ошибку, я завершил heroku run rake:migrate
без ошибок, но теперь, когда я иду, чтобы увидеть цитаты, предположим, www.example.com/quotes/new
я получаю эту ошибку на консоли:
ошибка
2018-05-29T17:15:29.527333+00:00 app[web.2]: Completed 500 Internal Server Error in 4ms (ActiveRecord: 1.7ms)
2018-05-29T17:15:29.528314+00:00 app[web.2]:
2018-05-29T17:15:29.528318+00:00 app[web.2]: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "quotes" does not exist
2018-05-29T17:15:29.528322+00:00 app[web.2]: LINE 5: WHERE a.attrelid = '"quotes"'::regclass
2018-05-29T17:15:29.528324+00:00 app[web.2]: ^
2018-05-29T17:15:29.528326+00:00 app[web.2]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2018-05-29T17:15:29.528328+00:00 app[web.2]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2018-05-29T17:15:29.528330+00:00 app[web.2]: FROM pg_attribute a LEFT JOIN pg_attrdef d
2018-05-29T17:15:29.528332+00:00 app[web.2]: ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2018-05-29T17:15:29.528333+00:00 app[web.2]: WHERE a.attrelid = '"quotes"'::regclass
2018-05-29T17:15:29.528335+00:00 app[web.2]: AND a.attnum > 0 AND NOT a.attisdropped
2018-05-29T17:15:29.528337+00:00 app[web.2]: ORDER BY a.attnum
2018-05-29T17:15:29.528339+00:00 app[web.2]: ):
2018-05-29T17:15:29.528341+00:00 app[web.2]: app/controllers/quotes_controller.rb:32:in `new'
20180527063820_create_quotes.rb
class CreateQuotes < ActiveRecord::Migration
def change
create_table :quotes do |t|
t.string :author
t.text :quote
t.text :image_url
t.timestamps null: false
end
end
end
quotes_controller.rb
require 'flickraw'
class QuotesController < ApplicationController
before_action :set_quote, only: [:show, :edit, :update, :destroy, :like]
before_action :authenticate_user!, except: [:index, :show]
# GET /quotes
# GET /quotes.json
def index
@quotes = Quote.all.order('created_at DESC').page params[:page]
if @quote && @quote.image_url.blank?
@quote.image_url = get_flickr_image_url(@quote)
@quote.save
end
#puts "using #{sort_column}"
#puts "#{params[:key]}"
end
# GET /quotes/1
# GET /quotes/1.json
def show
end
# GET /quotes/new
def new
@quote = current_user.quotes.build
end
# GET /quotes/1/edit
def edit
end
# POST /quotes
# POST /quotes.json
def create
@quote = current_user.quotes.build(quote_params)
respond_to do |format|
if @quote.save
format.html { redirect_to @quote, notice: 'Quote was successfully created.' }
format.json { render action: 'show', status: :created, location: @quote }
else
format.html { render action: 'new' }
format.json { render json: @quote.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /quotes/1
# PATCH/PUT /quotes/1.json
def update
respond_to do |format|
if @quote.update(quote_params)
format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @quote.errors, status: :unprocessable_entity }
end
end
end
# DELETE /quotes/1
# DELETE /quotes/1.json
def destroy
@quote.destroy
respond_to do |format|
format.html { redirect_to quotes_url }
format.json { head :no_content }
end
end
def like
if @quote.liked_by current_user
respond_to do |format|
format.html { redirect_to :back }
format.js
end
end
end
#Gives a random quote
private
# Use callbacks to share common setup or constraints between actions.
def set_quote
@quote = Quote.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def quote_params
params.require(:quote).permit(:author, :quote, :image_url)
end
def get_flickr_image_url(quote)
FlickRaw.api_key="f6825c919ed112e04e918353e711b02a"
FlickRaw.shared_secret="1989755619d0054f"
result = flickr.photos.search(:text => quote.most_significant_word, :per_page => 1, :safe_search => 1, :is_trending => true)
#Image used in case no result is found
biggest_url = "http://farm3.staticflickr.com/2862/10835118755_3757dab0a4_h.jpg"
result.each do |p|
info = flickr.photos.getInfo(:photo_id => p.id)
sizes = flickr.photos.getSizes(:photo_id => p.id)
photo_area = 0
sizes.each do |size|
calculate_area = size.width.to_f * size.height.to_f
puts "size of #{size.label} is #{100} x #{100} : #{size.source}"
if calculate_area > photo_area
photo_area = calculate_area
biggest_url = size.source
end
end
end
return biggest_url
end
end
Я пробовал почти все, как сброс базы данных pg и повторная миграция, но до сих пор ничего не помогало.