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
- <% for column in Noticia.content_columns %>
-
-
<%= column.human_name %>: <%=h @noticia.send(column.name)
%> - <% end %>
File feedxml.rhtml
- xml.instruct! :xml, :version=>“1.0”
- xml.rss(‘version’ => ‘2.0’) do
-
xml.channel do
-
xml.title('GEMCC News')
-
xml.link ('http://localhost:3000/home')
-
xml.description('Description.')
-
xml.language('en-us')
-
xml.pubDate('Sun, 9 Dez 2006 04:00:00 GMT')
-
xml.lastBuildDate('Sun, 9 Dez 2006 04:00:00 GMT')
-
for noticia in @noticia
-
xml.item do
-
xml.title(noticia.title)
-
@noticia = Noticia.find(noticia.id)
-
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
- def rss
- @noticia = Noticia.find(params[:id])
- end
- def feedxml
- @headers[“Content-Type”] = “application/rss+xml; charset=utf-8”
- @noticia = Noticia.find(:all)
- render_without_layout
- end
File noticias_controller.rb
- class NoticiasController < ApplicationController
- before_filter :authorize, :except => [:show]
- def index
-
list
-
render :action => 'list'
- end
-
GETs should be safe (see <a
href=‘URIs, Addressability, and the use of HTTP GET and POST’>URIs, Addressability, and the use of HTTP GET and POST)
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