Rss


#1

Hi,

I’m trying to do RSS in my page, using ruby. Something is appearing in
the browser, but I’m with some problems:
1 - If I’m not logged in, nothing appears in the bookmark.
2 - If I’m logged in, when I put another new in my data base, this one
doesn’t appear in the bookmark
3 - After closing the browser and close it again, the bookmark says
“Live Bookmark feed failed to load”.
To solve the first problem, I must change my “noticias_controller”… I
must clear the line
before_filter :authorize, :except => [:show]
but I think I’m using nothing more besides “show” from this controller.

Could you please tell me what is missing in my code?

File rss.rhtml

  1. <% for column in Noticia.content_columns %>
  2. <%= column.human_name %>: <%=h @noticia.send(column.name)
    %>
  3. <% end %>

File feedxml.rhtml

  1. xml.instruct! :xml, :version=>“1.0”
  2. xml.rss(‘version’ => ‘2.0’) do
  3. xml.channel do
    
  4.     xml.title('GEMCC News')
    
  5.     xml.link ('http://localhost:3000/home')
    
  6.     xml.description('Description.')
    
  7.     xml.language('en-us')
    
  8.     xml.pubDate('Sun, 9 Dez 2006 04:00:00 GMT')
    
  9.     xml.lastBuildDate('Sun, 9 Dez 2006 04:00:00 GMT')
    
  10.     for noticia in @noticia
    
  11.         xml.item do
    
  12.             xml.title(noticia.title)
    
  13.             @noticia = Noticia.find(noticia.id)
    
  14.             xml.description(@noticia.title + " - " +
    

@noticia.news)
17. xml.link(‘http://localhost:3000/home/rss/’ +
noticia.id.to_s)
18. xml.pubDate(‘Sun, 9 Dez 2006 04:00:00 GMT’)
19. xml.guid(‘http://localhost:3000/home/rss/’ +
noticia.id.to_s)
20. end
21. end
22. end
23. end

A small parte of the file home_controller.rb

  1. def rss
  2. @noticia = Noticia.find(params[:id])
  3. end
  4. def feedxml
  5. @headers[“Content-Type”] = “application/rss+xml; charset=utf-8”
  6. @noticia = Noticia.find(:all)
  7. render_without_layout
  8. end

File noticias_controller.rb

  1. class NoticiasController < ApplicationController
  2. before_filter :authorize, :except => [:show]
  3. def index
  4. list
    
  5. render :action => 'list'
    
  6. end
  7. GETs should be safe (see <a

href=‘http://www.w3.org/2001/tag/doc/whenToUseGet.html’>http://www.w3.org/2001/tag/doc/whenToUseGet.html)
11. verify :method => :post, :only => [ :destroy, :create, :update
],
12. :redirect_to => { :action => :list }
13.
14. def list
15. @noticia_pages, @noticias = paginate :noticias, :per_page =>
10, :order => ‘date DESC’
16. end
17.
18. def display
19. end
20.
21. def procura
22. @noticia_pages, @noticias = paginate :noticias, :per_page =>
10, :order => ‘title’,
23. :conditions => [‘title LIKE ?’, params[:noticia][:title]]
24. end
25.
26. def show
27. @noticia = Noticia.find(params[:id])
28. end
29.
30. def new
31. @noticia = Noticia.new
32. end
33.
34. def create
35. @noticia = Noticia.new(params[:noticia])
36. if @noticia.save
37. flash[:notice] = ‘Noticia was successfully created.’
38. redirect_to :action => ‘list’
39. else
40. render :action => ‘new’
41. end
42. end
43.
44. def edit
45. @noticia = Noticia.find(params[:id])
46. end
47.
48. def update
49. @noticia = Noticia.find(params[:id])
50. if @noticia.update_attributes(params[:noticia])
51. flash[:notice] = ‘Noticia was successfully updated.’
52. redirect_to :action => ‘show’, :id => @noticia
53. else
54. render :action => ‘edit’
55. end
56. end
57.
58. def destroy
59. Noticia.find(params[:id]).destroy
60. redirect_to :action => ‘list’
61. end
62.
63. def feedxml
64. @headers[“Content-Type”] = “application/rss+xml;
charset=utf-8”
65. @noticia = Noticia.find(:all)
66. render_without_layout
67. end
68. end