There are two models: User, who does the commenting (provided by Devise), and Audio, which they comment on. Each audios#show page should list all comments for that audio, and have a little form through which to submit another one.
I made Audio acts_as_commentable. Then I made sure Comment belongs_to :user, and User has_many :comments.
For the routes, I have
resources :audios do
resources :comments
end
Then, on the audios_controller,
def show
if user_signed_in?
@comment = @audio.comments.new
end
end
Then I wrote a simple form_for(@comment) form with a 'comment' field and a submit button. That's it.
The error I get upon loading the page is undefined method 'comments_path'. I googled this error, read the StackOverflow responses, and tried form_for(@audio, @comment) instead. This gets the error **can't write unknown attribute 'html'`.
I'm a little stumped; I've got the models and relationships sketched out on my notepad but I'm inexperienced and the use of things that I don't fully understand, like Devise behind the scenes, is throwing me for a loop. If someone could give me a tip on these routes/forms I would love it.
Try
or