Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment outside of controller/Model #107

Open
Rubioli opened this issue Feb 22, 2017 · 0 comments
Open

Comment outside of controller/Model #107

Rubioli opened this issue Feb 22, 2017 · 0 comments

Comments

@Rubioli
Copy link

Rubioli commented Feb 22, 2017

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant