From 4c3d622b3795836e1e7be4df303ee256a88b2812 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 21 Feb 2009 14:38:14 +0100 Subject: adding @node filter for publish action and setting a new member route for the nodes resource so that a put request on /nodes/id/publish will publish the current draft of a node --- app/controllers/nodes_controller.rb | 9 ++++++++- app/views/nodes/edit.html.erb | 2 ++ config/routes.rb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 1515fdf..6d400bc 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -2,7 +2,14 @@ class NodesController < ApplicationController layout 'admin' before_filter :login_required - before_filter :find_node, :only => [:create, :show, :edit, :update, :destroy] + before_filter :find_node, :only => [ + :create, + :show, + :edit, + :update, + :destroy, + :publish + ] def index @nodes = Node.root.descendants.paginate( diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 6848dfb..f457bc7 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -1,5 +1,7 @@

Nodes#edit

+<%= link_to 'Publish', publish_node_path, :method => :put %> +

Editing page

<%= I18n.locale %> diff --git a/config/routes.rb b/config/routes.rb index 6365186..ff9a13b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ ActionController::Routing::Routes.draw do |map| map.filter :locale map.resources :pages - map.resources :nodes + map.resources :nodes, :member => {:publish => :put} map.logout '/logout', :controller => 'sessions', :action => 'destroy' map.login '/login', :controller => 'sessions', :action => 'new' -- cgit v1.3