CGI Script Inside Rails?

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

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

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