i am actually following the book because am doing EXACTLY the same thing.this 
is my code, have a look at time .will appreciate corrections.i am sick of 
seeing the error message.

class InteractController < ApplicationController  def index   �...@products = 
Product.find_products_for_sale  end    def add_to_cart  product = 
Product.find(params[:id])�...@cart = 
find_cart �[email protected]_product(product)  rescue 
ActiveRecord::RecordNotFound     logger.error("Attempt to access invalid 
product #{params[:id]}")    flash[:notice] = "Invalid product"    redirect_to 
:action => 'index'end
def empty_cart  session[:cart] = nil   flash[:notice] = " Now,your cart is 
currently empty"   redirect_to :action => 'index'end  private
def redirect_to_index(msg)    flash[:notice] = msg   redirect_to :action => 
'index' end end Regards and Respects,


Kindness in thought leads to wisdom.
Kindness in speech leads to eloquence.
Kindness in action leads to love.



--- On Tue, 12/15/09, Norm Scherer <[email protected]> wrote:

From: Norm Scherer <[email protected]>
Subject: Re: [Rails] Need help...NameError in InteractController#add_to_cart
To: [email protected]
Date: Tuesday, December 15, 2009, 3:04 PM




  
  

 
Oluwayomi Oluwadara wrote:

  
    
      
        Hello,
        thank you for your time.I am actually developing an e
commerce website for selling books online.the find_cart method is mean
to find the cart displayed at the front end-for the users buying
stuffs.Your help wil be appreciated,am just 2 weeks old in RoR

        

        Regards and Respects,

        
        
      
    
  

In the sample application used in 'Agile Web Development with Rails'
they define a Cart class (which is not derived from
ActiveRecord::Base).  In their StoreController class they define a
find_cart method as:

[code]

def find_cart 

  @cart = (session[:cart] ||= Cart.new)

end

[/code]

Whether this has any applicability to your case is impossible to know
without knowing a lot more about your application.

 




--

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.





      

--

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