I have a JSON API where a user can update a post and related details to that post. To simplify the process the user just fills in one hash and we don't expose our architecture. What I did here works but I would like to know if their is a better way. This smells to me, but I don't know why...
def update params['blog_post'] = params.delete 'post' @blog_post.update_attributes blog_post_params update_blog_post_groups if params['blog_post']['group_ids'] params['blog_post_details'] = params.delete 'blog_post' @blog_post.blog_post_details.update_attributes blog_post_details_params render :blog_post, status: 200 end
blog_post_details_params are strong_parameter methods.
It seems that I should use first : accepts_nested_attributes_for