class FeedController < ApplicationController
+
+ skip_before_filter :verify_authenticity_token
+
def index
@feeds = FeedItem.find(:all, :select => 'DISTINCT feed_name')
respond_to do |format|
end
def update
- item = FeedItem.find_by_feed_name_and_title(params[:feed_item][:feed_name], params[:feed_item][:title])
+ item = FeedItem.find_by_feed_name_and_title(params[:feed_name], params[:title])
if item
- if params[:feed_item][:description] == ''
+ if params[:description] == ''
item.destroy
else
- item.update_attribute(:description, params[:feed_item][:description])
+ item.update_attribute(:description, params[:description])
end
else
- FeedItem.create(params[:feed_item])
+ FeedItem.create(:feed_name => params[:feed_name],
+ :title => params[:title],
+ :description => params[:description])
end
- redirect_to feed_url(params[:feed_item][:feed_name])
+ redirect_to feed_url(params[:feed_name])
end
end
<h1>Feeds available</h1>
-<% form_for :feed_item, :url => update_url do |form| %>
- <p>Set feed <%= form.text_field :feed_name, :size => 20 %>
- to include <%= form.text_field :title, :size => 30 %>
- containing <%= form.text_field :description, :size => 50 %>
- <%= submit_tag %></p>
+<% form_tag :action => 'update' do %>
+ <p>Set feed <%= text_field_tag :feed_name, '', :size => 20 %>
+ to include <%= text_field_tag :title, '', :size => 30 %>
+ containing <%= text_field_tag :description, '', :size => 50 %>
+ <%= submit_tag 'Update' %></p>
<% end %>
<ul>
<h1>Contents of feed <%= h params[:feed_name] %></h1>
<p><%= link_to("List of all feeds", index_url) %></p>
-<% form_for :feed_item, :url => update_url(params[:feed_name]) do |form| %>
- <p>Set feed <%= form.text_field :feed_name, :size => 20, :value => h(params[:feed_name]) %>
- to include <%= form.text_field :title, :size => 30 %>
- containing <%= form.text_field :description, :size => 50 %>
- <%= submit_tag %></p>
+<% form_tag :action => 'update' do %>
+ <p>Set feed <%= text_field_tag :feed_name, h(params[:feed_name]), :size => 20 %>
+ to include <%= text_field_tag :title, '', :size => 30 %>
+ containing <%= text_field_tag :description, '', :size => 50 %>
+ <%= submit_tag 'Update' %></p>
<% end %>
+
<dl>
<% for item in @feed_items %>
<dt><%= h item.title %></dt>
--- /dev/null
+<html>
+ <head>
+ <title>Form: <%= controller.action_name %></title>
+ </head>
+ <body>
+ <%= yield :layout %>
+ </body>
+</html>