About Page id Display in Rails6 RSS Output

Asked 1 years ago, Updated 1 years ago, 360 views

Unable to get page number from rss.
Please tell me how to solve it.

View in RSS
http://localhost:3000/articles/feed

<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
    <channel>
        <title> 1K Extreme: Updates </title>
        <link>https://www.onekextreme.com/</link>
        <description>1K Extreme Blog: New </description>
            <item>
                <title> Cabbage</title>
                <link>https://www.onekextreme.com/articles/#{article.id}</link>
                <description>tesyqqqqqqqqqqqqqqqqqqq;/description>
                <pubDate>2022-11-2709:18:24 + 0900</pubDate>
            </item>
    </channel>
</rss>

Regarding #{article.id}, I would like to display the id of the article, but
#{article.id} is displayed as is in text.
I would like to obtain the id number as follows.

<link>https://www.onekextreme.com/articles/80</link>

The view and controller are configured as follows:

views/articles/feed.rss.erb

<rss version='2.0'>
    <channel>
        <title> 1K Extreme: Updates </title>
        <link>https://www.onekextreme.com/</link>
        <description>1K Extreme Blog: New </description>

        <%@articles.each do |article|%>
            <item>
                <title><%=article.title%></title>
                <link>https://www.onekextreme.com/articles/#{article.id}</link>
                <description><%=article.content1%></description>
                <pubDate><%=article.created_at%>/pubDate>
            </item>
         <%end%>
    </channel>
</rss>

articles_controller.rb

defeed
  @articles=Article.all.order(created_at::desc).page(params[:page]).per(6)
end

ruby-on-rails ruby

2022-12-10 08:43

1 Answers

<link>https://www.onekextreme.com/articles/<%=article.id%></link>

If you want to use URL helper

<link><%=article_url(article)%>/link>


2022-12-11 09:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.