Steve, are you thinking about something like this in terms of code?
render json: SearchClient.new(@clients)
#or
render json: ContractWon.new(@clients)
class SearchClient
def initialize(clients)
@clients = clients
end
def to_json(options=nil)
@clients.to_json(only: %w(foo bar)
end
end
class ContractWon
def initialize(clients)
@clients = clients
end
def to_json(options=nil)
@clients.to_json(only: %w(baz other)
end
end
That's basically the approach I've been using lately, and it works quite
fine for my needs :).
On Thursday, June 21, 2012 11:12:40 PM UTC-3, Steve Klabnik wrote:
>
> I think this would be useful, but I'm not sure that this just means
> that there shouldn't be two serailizers instead of putting both in one
> class.
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/5gm_TzguGugJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.