class InventoryController < ApplicationController

  def index
      @albums=Album.find(:all)
      @cart=find_cart
  end



  def add_to_cart
          itemType=params[:itemType]
               productId=(params[:id]) #parameter passed in from "add to
cart" submission, it's either 1 or 2 in this case

               if itemType=='album'
                    product_temp=Album.find(productId)
                    dest='/inventory'
                end
                if itemType=='dvd'
                    product_temp=Dvd.find(productId)
                    dest='/inventory/dvd'
                end


product=Product.new(itemType,product_temp.title,product_temp.price)
               @cart=find_cart
               @cart.add_product(product)    #add the album to the cart in
the sessions
    redirect_to dest
  end

  def check_out
      @cart=find_cart
      redirect_to '/inventory/checkOut'
    end

  def review
      @cart=find_cart #for shopping car display in the sidebar
      @title=(params[:title])
      @itemType=(params[:itemType])

      if @itemType=='album' #must be a better way to reduce the amount of
redundant code
          @album=Album.find_by_title(@title)
          @review=Review.new
          @[EMAIL PROTECTED] #Review.find(:all, :conditions => ["album
= ?", @title])
      end
      if  @itemType=='dvd'
          @dvd=Dvd.find_by_title(@title)
          @review=Review.new
          @[EMAIL PROTECTED] #Review.find(:all, :conditions => ["album =
?", @title])
      end
  end

  def dvd
      @cart=find_cart
      @dvds=Dvd.find(:all)
    end

end



The method is "check_out"...i had it in my application.rb file originally,
tried it in this one and still no change...


On Sat, Sep 27, 2008 at 8:23 PM, Phillip Koebbe <
[EMAIL PROTECTED]> wrote:

>
> > You'll want to put the shared method in app/controllers/application.rb
>
> Unless find_cart is used only in the one controller, then you just need
> to turn it into a before_filter:
>
> class MainController < ApplicationController
>    before_filter :set_cart
>
>    def index
>    end
>
>    def what_ever
>    end
>
>    private
>
>    def set_cart
>       @cart = find_cart
>    end
> end
>
> Peace.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to