Hi. Not sure if this helps, but I wrote a gem to deal with this exact use case: to define a clear mapping between incoming payloads (that I might have no control of) and the internal data structures that need to feed to my models.
https://github.com/ismasan/hash_mapper It only really make sense if you have lots of mismatching fields or the nested structures are different. For simpler cases just mutating what you need is probably enough. You might find it useful anyway. On Monday, 31 March 2014 14:02:48 UTC+1, Àlex vinyals wrote: > > Hi, > > Assume I'm doing an API in Rails 4 with StrongParameters, and I got a > model like Pricing, with many Prices. > > I want my API to support in one endpoint nested attributes for the Prices > of a Pricing. > > The consumer of the API doesn't care that I am using Rails, so he sends me > the nested attributes of the Prices as :prices, but Rails is expecting > :prices_attributes > > And I am just wondering if it could be possible to bring extra options on > Strong Parameters, to rename keys like: > > params.permit(:prices, :description, ...) > params.rename(:prices, :prices_attributes) > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.