> I'm not sure that's something we intend to support. You should be
> able to use, either :methods=>[:user_id] or a builder template to
> achieve what you're after?
>From the RDoc:
to_xml is controlled with :only, :except, :skip_instruct, :skip_types
and :dasherize. The :only and :except options are the same as for the
attributes method. To not have the column type included in the XML
output, set :skip_types to true.
While that works great when you want to remove some attributes,
sometimes you simply want to add one attribute, creating a builder
template for that seems like an overkill to me.
Can you explain what you mean by using :methods=>[:user_id]?
Would it be bad to add another method to to_xml, such as #add?
One could do:
render :xml => @photo.to_xml( :except
=>[:id, :filename, :updated_at, :height, :width], :add => {:user_id =>
@photo.user.id})
What do you think?
-Matt
On Nov 15, 8:20 pm, "Michael Koziarski" <[EMAIL PROTECTED]> wrote:
> > I'm adding attributes to the object before converting it to xml,
> > something like that:
>
> > @photo
> > @photo[:user_id] = @photo.user.id
>
> > render :xml => @photo.to_xml( :except =>
> > [:id, :filename, :updated_at, :height, :width], :skip_types => true)
>
> > Maybe the problem is that you can't easily add an attribute.
>
> I'm not sure that's something we intend to support. You should be
> able to use, either :methods=>[:user_id] or a builder template to
> achieve what you're after?
>
>
>
> > -Matt
>
> > On Nov 15, 6:38 pm, "Michael Koziarski" <[EMAIL PROTECTED]> wrote:
> > > > Here is a really tiny patch to avoid another annoying deprecation
> > > > warning :)
>
> > > >http://dev.rubyonrails.org/ticket/10181
>
> > > What are you doing that triggers a warning?
>
> > > Person.columns_hash["created_at"].type
> > > => :datetime
>
> > > Type's our own attribute, not 'class'?
>
> > > --
> > > Cheers
>
> > > Koz
>
> --
> Cheers
>
> Koz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
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
-~----------~----~----~----~------~----~------~--~---