From: Neil Smith Date: Fri, 17 Jul 2009 19:19:21 +0000 (+0000) Subject: Fixed forms to allow for exernal driving of the site X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=68d23ac1cc9c0f64f5dff661c3c4fe36621948d6;p=feedcatcher.git Fixed forms to allow for exernal driving of the site --- diff --git a/app/controllers/feed_controller.rb b/app/controllers/feed_controller.rb index 2eddc8c..71ab1df 100644 --- a/app/controllers/feed_controller.rb +++ b/app/controllers/feed_controller.rb @@ -1,4 +1,7 @@ class FeedController < ApplicationController + + skip_before_filter :verify_authenticity_token + def index @feeds = FeedItem.find(:all, :select => 'DISTINCT feed_name') respond_to do |format| @@ -17,17 +20,19 @@ class FeedController < ApplicationController 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 diff --git a/app/views/feed/index.html.erb b/app/views/feed/index.html.erb index cd75a00..b9e082a 100644 --- a/app/views/feed/index.html.erb +++ b/app/views/feed/index.html.erb @@ -1,10 +1,10 @@

Feeds available

-<% form_for :feed_item, :url => update_url do |form| %> -

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 %>

+<% form_tag :action => 'update' do %> +

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' %>

<% end %>