コメント モデルを作成したところ、なんらかの理由で自分の曲の投稿が song#index に表示されなくなりました。
要するに、最初は典型的な CRUD 機能を備えた songs_controller しかありませんでした。新しい曲を作成すると、インデックスに投稿されて表示されます。ただし、コメント モデルを作成した後、曲は表示されなくなります (または、完全に作成されることさえあります)。
以下の要点にさまざまなページを添付しました。リクエストに応じて、追加のページでこの投稿を更新します。
https://gist.github.com/Apane/affe60c5b9d0d33cbaf8
コメント.rb
class Comment < ActiveRecord::Base
belongs_to :song
belongs_to :user
validates_presence_of :author_name, :content
end
song.rb
class Song < ActiveRecord::Base
has_many :comments, :dependent => :destroy
belongs_to :user
has_attached_file :track,
:url => "/assets/songs/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/songs/:id/:style/:basename.:extension"
validates_attachment :track, :presence => true
validates :title, length: { minimum: 10 }
validates :bio, length: { maximum: 300 }
end
user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :songs
end