I am working with nested attributes and strong params and I’ve seen two different ways of nesting attributes in strong params.
Take this example:
class Post < ActiveRecord::Base
has_many :comments
accepts_nested_attributes, :comments
class Comments < ActiveRecord::Base
belongs_to :post
I have seen these two ways of nesting params for comments in the Post Controller, is there a difference?
params.require(:post)
.permit(:title, :id, :author, :comment => [:id, :content, :post_id, :user_id])
or
params.require(:post)
.permit(:title, :id, :author, comments_attributes: [:id, :content, :post_id, :user_id])
They look similar...normally I would think that one was an earlier version, but I believe strong params is relatively new. What is the difference?