describe 'nested attributes on articles (which has_many comments)' do before do @hash = { "article" => { "title" => "Test", "body" => "test body", "comments_attributes" => { '0'=>{"author" => "John", "content" => "great"}, '1'=>{"author" => "Mary", "content" => "awful"} } } } @params = ActionController::Parameters.new @hash end it 'shows how to permit nested parameters' do attributes = @params. require(:article). permit(:title, comments_attributes: [:author, :content])[:comments_attributes]. must_equal @hash['article']['comments_attributes'] endend
http://www.carreno.me/articles/understanding-strong-parameters-in-rails-4