I'm trying to have a simple button to update for each Comment through a submit form. Here is my View code:
<% @comments.each do |comment| %>
<%= form_for comment, url: article_comment_path(comment.article, comment), method: :patch do |f| %>
<%= hidden_field_tag :update_time, Time.now %>
<%= f.submit "Confirm" %>
<% end %>
<% end %>
Comments Controller Update Action Code:
def update
@article = Article.friendly.find(params[:article_id])
@comment = @user.comments.find(params[:id])
if @comment.update(comment_params)
redirect_to @comments
else
render article_comments_path(@article)
end
end
private
def comment_params
params.require(:comment).permit(:date, :note)
end
With the code above, I'm getting this error:
param is missing or the value is empty: comment - the error highlights the params.require line in the private declaration