RSS

A

Adriana Sucena

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. <p>
3. <b><%= column.human_name %>:</b> <%=h @noticia.send(column.name)
%>
4. </p>
5. <% end %>


File feedxml.rhtml
1. xml.instruct! :xml, :version=>"1.0"
2.
3. xml.rss('version' => '2.0') do
4. xml.channel do
5. xml.title('GEMCC News')
6. xml.link ('http://localhost:3000/home')
7. xml.description('Description.')
8. xml.language('en-us')
9. xml.pubDate('Sun, 9 Dez 2006 04:00:00 GMT')
10. xml.lastBuildDate('Sun, 9 Dez 2006 04:00:00 GMT')
11.
12. for noticia in @noticia
13. xml.item do
14. xml.title(noticia.title)
15. @noticia = Noticia.find(noticia.id)
16. 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.
5. def feedxml
6. @headers["Content-Type"] = "application/rss+xml; charset=utf-8"
7. @noticia = Noticia.find:)all)
8. render_without_layout
9. end

File noticias_controller.rb
1. class NoticiasController < ApplicationController
2.
3. before_filter :authorize, :except => [:show]
4.
5. def index
6. list
7. render :action => 'list'
8. end
9.
10. # 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</a>)
11. verify :method => :post, :eek:nly => [ :destroy, :create, :update
],
12. :redirect_to => { :action => :list }
13.
14. def list
15. @noticia_pages, @noticias = paginate :noticias, :per_page =>
10, :eek:rder => 'date DESC'
16. end
17.
18. def display
19. end
20.
21. def procura
22. @noticia_pages, @noticias = paginate :noticias, :per_page =>
10, :eek:rder => '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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top