I'm using wrap_parameters and ActiveRecord's single table inheritance
pattern.

I have a base class "Entity", and two types derived from it: "Person" and
"Group".

What I'd like to do is PUT a Person or Group object to
EntityController#update.

Unfortunately, this causes wrap_parameters to wrap for type "Entity"
instead of Person or Group.

Is there a way to programmatically change wrap_parameter, e.g. so I can
establish a before_filter that sets the proper child class name based on
params[:type]?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/rHNFOt2uBNAJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Max Shytikov at Nov 14, 2012 at 6:03 pm
    Hi Christopher,

    You can try this for example

    wrap_parameters Entity, :include =>(Person.attribute_names + Group.
    attribute_names), :format => :json


    On Thursday, November 8, 2012 2:07:33 AM UTC+2, Christopher Thielen wrote:

    I'm using wrap_parameters and ActiveRecord's single table inheritance
    pattern.

    I have a base class "Entity", and two types derived from it: "Person" and
    "Group".

    What I'd like to do is PUT a Person or Group object to
    EntityController#update.

    Unfortunately, this causes wrap_parameters to wrap for type "Entity"
    instead of Person or Group.

    Is there a way to programmatically change wrap_parameter, e.g. so I can
    establish a before_filter that sets the proper child class name based on
    params[:type]?
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/sLUNh_iRi-sJ.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 8, '12 at 1:25p
activeNov 14, '12 at 6:03p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase