Przeglądaj źródła

Fix #15 - when deleting a feed from a layer, just delete the relationship

master
Adrian Short 11 lat temu
rodzic
commit
696ebc158a
4 zmienionych plików z 26 dodań i 11 usunięć
  1. +9
    -9
      app/controllers/feeds_controller.rb
  2. +10
    -0
      app/controllers/layers_controller.rb
  3. +1
    -1
      app/views/layers/show.html.haml
  4. +6
    -1
      config/routes.rb

+ 9
- 9
app/controllers/feeds_controller.rb Wyświetl plik

@@ -91,15 +91,15 @@ class FeedsController < ApplicationController

# DELETE /feeds/1
# DELETE /feeds/1.json
def destroy
@feed = Feed.find(params[:id])
@feed.destroy
respond_to do |format|
format.html { redirect_to feeds_url, notice: 'Feed deleted OK' }
format.json { head :no_content }
end
end
# def destroy
# @feed = Feed.find(params[:id])
# @feed.destroy
#
# respond_to do |format|
# format.html { redirect_to feeds_url, notice: 'Feed deleted OK' }
# format.json { head :no_content }
# end
# end
def fetch
@feed = Feed.find(params[:id])


+ 10
- 0
app/controllers/layers_controller.rb Wyświetl plik

@@ -84,4 +84,14 @@ class LayersController < ApplicationController
format.json { head :no_content }
end
end

# DELETE /layers/1/delete_feed
# This only deletes the relation between the layer and the feed. The feed (and its posts) are retained.
# Currently there's no way for the user to actually delete a feed completely.
def delete_feed
@layer = Layer.find(params[:id])
@feed = Feed.find(params[:feed_id])
@layer.feeds.delete(@feed)
redirect_to @layer, notice: "Deleted feed #{@feed.title} from this layer"
end
end

+ 1
- 1
app/views/layers/show.html.haml Wyświetl plik

@@ -38,7 +38,7 @@
= (time_ago_in_words(f.last_fetched) + " ago").gsub(/ +/, "&nbsp;").html_safe
%td= link_to "Fetch", fetch_feed_url(f), :class => "button"
%td= link_to 'Edit', edit_feed_path(f), :class => "button"
%td= link_to 'Delete', f, :confirm => "Delete #{f.title} and all its posts?", :method => :delete, :class => "button"
%td= link_to 'Delete', delete_feed_layer_path(:feed_id => f.id), :confirm => "Delete #{f.title} from this layer?", :method => :delete, :class => "button"

%tr
%td


+ 6
- 1
config/routes.rb Wyświetl plik

@@ -2,7 +2,12 @@ Apollo::Application.routes.draw do
get "logout" => "sessions#destroy", :as => "logout"
get "login" => "sessions#new", :as => "login"

resources :layers
resources :layers do
member do
delete "delete_feed"
end
end

resources :users
resources :sessions
resources :password_resets


Ładowanie…
Anuluj
Zapisz