Missin template on ruby on rails -
i have 2 methods on catalog_controler.rb
def latest @boxes = box.latest 5 @page_title = 'novedades' end def rss latest render :layout => false end
end on app/views/catalog folder have xml file , rss.xml.erb
xml.instruct! :xml, :version=>"1.0", :encoding=>"utf-8" xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") xml.channel xml.title @page_title xml.link(url_for(:action => "index", :only_path => false)) xml.language "en-us" xml.ttl "40" xml.description "international boxes" book in @books xml.item xml.title(book.title) xml.description("#{box.model}) xml.pubdate(book.created_at.to_s(:long)) xml.guid(url_for(:action => "show", :id => book, :only_path => false)) xml.link(url_for(:action => "show", :id => book, :only_path => false)) end end end end
but gives missing template error:
missing template catalog/rss, application/rss {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. searched in: * "/home/user/desktop/eshop_con_css/app/views"
how can show xml file on browser?
read mimeresponds's respond_to
method. should below, please change block content per requirement.
def rss @latest = latest respond_to |format| format.xml { render xml: @latest } end end
respond_to
can adopt various different mimes including popular .json
, handy in building/working-with apis.
Comments
Post a Comment