Hi,
I''m trying to insert a string component into what was found by a find
search.
E.g.
do a
@version = Version.find("270")
@path = "somestring"
And I would like to stick the @path string into @version
then later do a
render :xml => @version
in order to produce
<versions>
<version>
<id>"270"</id>
.
.
.
<path>"somestring"</path>
</version>
<version/>
</versions>
Is this possible? The value of @path is not necessarily a result from
a search in the db so I can''t combine two searches via something like
a find_by_sql or include.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Martin Streicher
2009-Mar-05 23:08 UTC
Re: Insert some value into a result of a find in a db.
Should be no problem. You can add an attribute to @version and it will be emitted when you render. Try it in the console. @version = Version.find(...) @version[''path''] = ''somestring'' @version.to_xml --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
cinderedMonkey
2009-Mar-05 23:34 UTC
Re: Insert some value into a result of a find in a db.
Hey that''s great! Simple and sweet. Can I set the type? As it stands it''s coming out as type=\"NilClass\" On the flip side, can I also remove the type info? thanks On Mar 5, 6:08 pm, Martin Streicher <martin.streic...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Should be no problem. You can add an attribute to @version and it will > be emitted when you render. > > Try it in the console. > > @version = Version.find(...) > @version[''path''] = ''somestring'' > @version.to_xml--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---