Both.
Use wrap_parameters, Rails will ensure that params patching the controller
name are nested, so external dependencies can still interface with the API
standard.
Here is what I throw in my application_controller.rb
def self.inherited(subclass)
return unless (model_class =
subclass.controller_name.classify.singularize.try(:safe_constantize))
nested_attributes_names = if
model_class.method_defined?(:nested_attributes_options)
model_class.nested_attributes_options.keys.map do |key|
key.to_s.concat('_attributes').to_sym
end
else
[]
end
subclass.wrap_parameters include: (model_class.try(:attribute_names) ||
[]) + nested_attributes_names
end
On Monday, February 25, 2013 at 3:49:46 PM UTC-7, Brian Campbell wrote:
>
> Rails loves it when your forms post JSON back to the server with a root
> key...
> *{"user": {"name": "Joe"} }*
>
> By default (using $resource in v1.1.3) Angular seems to prefer a flat
> object without a root key...
> *{"name": "Joe"}*
>
> I'm curious how folks have solved this and whether they did so server or
> client side?
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.