REST controller with up and down for model that acts_as_list

Hi,

I have the following models

class Department < ActiveRecord::Base
has_many :products
end

class Product < ActiveRecord::Base
belongs_to :department
acts_as_list :scope => :department_id’
end

When I look at a list of products for a particular department I have
up and down buttons to re-order the products. Currently my controller
is something like this

class ProductController < ApplicationController
def up
Product.find(params[:id]).move_higher
end
def down
Product.find(params[:id]).move_lower
end
end

This doesn’t fit the the REST idea of only UPDATE for making changes.
How do I rework this to be more REST friendly?

Thanks,
Peter

How do I rework this to be more REST friendly?
Not everything is necessarily REST. You could set up your
simply_restful route like so:

map.resource :product, :member => { :up => :post, :down => :post }

This sets up routes for up and down as POST actions.

POST /products/1;up
POST /products/1;down

up_product_url()
down_product_url()

On 7/22/06, Rick O. [email protected] wrote:

up_product_url()
down_product_url()

Thanks, Rick. I am really trying to see where REST fits and where RPC
works better. It seems to me like RPC is better in this case but with
all of DHH’s hype about pure REST I am trying to use it wherever
possible to try it out.

Thanks again,
Peter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs