前提・実現したいこと
railsでテーブル結合をしたいのですが、ローカルサーバーではできるのに、herokuにデプロイすると、エラーが出ます。
発生している問題・エラーメッセージ
heroku logsをすると、以下のエラーがありました。
No operator matches the given name and argument types. You might need to add explicit type casts.
該当のソースコード
posts_controller.rb
@posts=Post.left_joins(:tickets).group(:content)
post.rb
class Post < ApplicationRecord has_many :tickets validates :content, {presence: true,length: {maximum:140},uniqueness: true} end
ticket.rb
class Ticket < ApplicationRecord belongs_to :post validates :ticket_id, {presence: true, uniqueness: true} end
class CreatePosts < ActiveRecord::Migration[6.0] def change create_table :posts do |t| t.string :content t.timestamps end end end
class CreateTickets < ActiveRecord::Migration[6.0] def change create_table :tickets do |t| t.string :post_id t.string :ticket_id t.string :phonenumber t.integer :used t.timestamps end end end
補足情報(FW/ツールのバージョンなど)
ruby rails
ローカルではsqlite herokuではpgを使っています。
回答1件
あなたの回答
tips
プレビュー