Comment outside of controller/Model
Opened this issue · 0 comments
Rubioli commented
I have models Album
& Picture
.
Album
model:
class Album < ActiveRecord::Base
has_many :pictures
accepts_nested_attributes_for :pictures, reject_if: :all_blank, allow_destroy: true
end
Picture
model:
class Picture < ActiveRecord::Base
acts_as_commentable
belongs_to :album
end
In my albums#show
view, I have all pictures that belongs to the album. I want to add Comments for each picture.
How can I added it? Since now in my controller I do:
#AlbumsController
@picture = Picture.find(params[:id])
@new_comment = Comment.build_from( @picture, current_user, "" )
But this gives me same id
for all pictures commentable_id
and that id
is the album's id
.
How can I do this correctly?
Thanks in advanced!