0

I need to add a link to a rss page but i don't know how

def index
    @boxes = Box.paginate :page => params[:page], :order => "boxes.id desc", :per_page => 5,
                       :include => [:suppliers, :manufacturer]
    @page_title = 'Catálogo'

respond_to do |format|
  format.html
  format.xml  { render :xml => @boxes }
  format.rss  { render :layout => false }
end
end

the url to access is http://localhost:3000/catalog.rss but i don't know how to make it like this <%= link_to 'Canal RSS', :action => 'index' %>

Pavan
  • 33,316
  • 7
  • 50
  • 76
  • Have a look at this http://stackoverflow.com/questions/3951235/how-do-i-make-an-rss-atom-feed-in-rails-3?rq=1 It will help you for sure. – Pavan Jun 02 '14 at 11:57

1 Answers1

0

In your routes.rb, you add the route first:

get 'catelog' => '<YOUR_CONTROLLER_NAME>#index', :constraints => {:format => :rss}

Then you can use it like this:

<%= link_to 'Canal RSS', catelog_url %>

catelog is the route prefix. You can run rake routes to see it.

Steven Yap
  • 188
  • 6
  • I have to redirect to catalog/rss i'am trying with `get 'catelog' => 'catalog#rss', :constraints => {:format => :rss}` but it raises a template missin error. – user3613349 Jun 06 '14 at 21:07