In the depot example we use a "Empty cart" button to empty the cart.
However, Instead of clicking the "Empty Cart" button, we want to call
a script from inside a .SWF(Flash) object to do it.
How do we write a .rb script to do something in the Rails
environment?
-Frank
~/rails/depot/app/controllers/store_controller.rb
=======class StoreController < ApplicationController
before_filter :find_cart, :except => :empty_cart
def index
@products = Product.find_products_for_sale
@cart = find_cart
end
def add_to_cart
begin
product = Product.find(params[:id])
rescue ActiveRecord::RecordNotFound
logger.error("Attempt to access invalid product #{params[:id]}")
redirect_to_index("Invalid product")
else
@cart = find_cart
@current_item = @cart.add_product(product)
redirect_to_index unless request.xhr?
end
end
def empty_cart
session[:cart] = nil
redirect_to_index
end
end
==============
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 14 May 2008, at 06:29, Merv wrote:> > In the depot example we use a "Empty cart" button to empty the cart. > However, Instead of clicking the "Empty Cart" button, we want to call > a script from inside a .SWF(Flash) object to do it. > > How do we write a .rb script to do something in the Rails > environment?Why can''t your flash object make the same http request that clicking on the button would have done ? Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---