Skip to content

Instantly share code, notes, and snippets.

@xenda
Created June 13, 2011 00:23
Show Gist options
  • Save xenda/1022160 to your computer and use it in GitHub Desktop.
Save xenda/1022160 to your computer and use it in GitHub Desktop.
class Admin::SendListsController < InheritedResources::Base
layout 'admin'
before_filter :authenticate_user!
respond_to :xml, :json
before_filter :setup_send_list, :only => :new
after_filter :update_stock, :only => [:create,:update]
def new
new!{
#@send_list.destination = Store.first
@send_list.save
@send_list_items = @send_list.send_list_items
@new_item = SendListItem.new({:send_list_id => @send_list.id})
}
end
def edit
edit!{
@send_list_items = @send_list.send_list_items
@new_item = SendListItem.new({:send_list_id => @send_list.id})
}
end
def create
@send_list = SendList.new(params[:send_list])
create!
session[:active_send_list] = nil
end
def update
update!
session[:active_send_list] = nil
end
private
def setup_send_list
@send_list = session[:active_send_list] ? SendList.find(session[:active_send_list]) : SendList.create
session[:active_send_list] ||= @send_list.id
end
def update_stock
@send_list.update_stock
end
end
class Admin::SendListsController < InheritedResources::Base
include Bentou::Controllers::Administrable
include Bentou::Controllers::StatusClosable
include Bentou::Controllers::ProductStockReflectable
include Bentou::Controllers::DetailsManager
include Bentou::Controllers::SessionStorable
def update
update! do
admin_send_list_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment