Forum: Ruby on Rails how to display links inside my rss description?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-02-17 03:32
(Received via mailing list)
Posts: 76
how to display links inside my rss description?
hey all,
I have that in my rxml:
xml.instruct!

xml.rss "version" => "2.0", "xmlns:dc" =>
"http://purl.org/dc/elements/1.1/" do
  xml.channel do
  xml.title _('My RSS')
  xml.link url_for(:only_path=> false,
       :controller=>'authors',
       :action => 'list')
  xml.pubDate CGI.rfc1123_date(@items.first.updated_at)
  xml.description _("feed of the day")
  @items.each do |item|
    xml.item do
    xml.title item.title
    xml.link url_for(:only_path => false,
        :controller => 'items',
        :action => 'show',
        :id => list)
    xml.description item.authors.collect do |author|
     link_to(author.name,:only_path => false,
        :controller => 'items',
        :action => 'show',
        :id => item.id)

    end
   xml.pubDate CGI.rfc1123_date(list.updated_at)
    xml.guid url_for(:only_path => false,
        :controller => 'items',
        :action => 'show',
        :id => item)
    xml.author h("no one")
        end
  end
end
end

but then i get that error:
XmlMarkup cannot mix a text argument with a block

Extracted source (around line #18):

15:   :controller => 'items',
16:        :action => 'show',
17:        :id => list)
18:    xml.description item.authors.collect do |author|
19:     link_to(author.name,:only_path => false,
20:        :controller => 'items',
21:        :action => 'show',
22:        :id => item.id)

any idea how I should do this?

Thanx in advance

Pat
8310c5a7c769345114597bcdef111488?d=identicon&s=25 Ben Munat (Guest)
on 2007-02-17 08:09
(Received via mailing list)
Patrick Aljord wrote:
> Posts: 76
> how to display links inside my rss description?

It doesn't look like you're having trouble with any links... looks like
Builder doesn't like you calling a block as an argument to a tag (via
method_missing):

>     xml.description item.authors.collect do |author|
>      link_to(author.name,:only_path => false,
>         :controller => 'items',
>         :action => 'show',
>         :id => item.id)
>
>     end

I think you want braces around the content (the block) being passed to
xml.description:

   xml.description {
     item.authors.collect do |author|
       link_to(author.name,:only_path => false,
         :controller => 'items',
         :action => 'show',
         :id => item.id)
     end
   }


Looks to me like you also have some typos in there, unless they're
features of Builder of which I'm not aware... in particular there is a
'_' character before a '(' in two places:

   xml.title _('My RSS')

and

   xml.description _("feed of the day")

Good luck

b
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2007-02-17 15:46
(Received via mailing list)
On 17-Feb-07, at 2:08 AM, Ben Munat wrote:

>
> Patrick Aljord wrote:
>> Posts: 76
>> how to display links inside my rss description?
>

sorry  - just noticed this thread.

this thread will show you how to use resource_feeder
(render_rss_feed_for) to render regular old rhtml views for rss/atom
descriptions.

http://groups.google.com/group/rubyonrails-talk/br...
2b920da418dc9363/beec22ed5fa26fea?lnk=gst&q=&rnum=13#beec22ed5fa26fea

Cheers,
Jodi
General Partner
The nNovation Group inc.
www.nnovation.ca/blog
997433f165140d58f52b8c0d1d005dc1?d=identicon&s=25 Patrick Aljord (Guest)
on 2007-02-17 16:24
(Received via mailing list)
thanx a lot.

On 2/17/07, Ben Munat <bmunat@gmail.com> wrote:
> Looks to me like you also have some typos in there, unless they're
> features of Builder of which I'm not aware... in particular there is a
> '_' character before a '(' in two places:
>
>    xml.title _('My RSS')
>
> and
>
>    xml.description _("feed of the day")
>
this is not a typo, it's just ruby gettext synthax :)
8310c5a7c769345114597bcdef111488?d=identicon&s=25 Ben Munat (Guest)
on 2007-02-17 20:13
(Received via mailing list)
Patrick Aljord wrote:
>>
>>    xml.description _("feed of the day")
>>
> this is not a typo, it's just ruby gettext synthax :)

Ah, cool... so I taught you something and you taught me something! :-)

b
This topic is locked and can not be replied to.