Displaying 20 results from an estimated 47 matches for "find_cart".
2006 Sep 03
2
Undefined method "xxx" of a model when calling a helper
...ms.each do |l|
return l if l.id == id
end
end
def initialize
@line_items = []
end
def empty!
initialize
end
def empty?
return true if @line_items.empty?
false
end
end
And I have some helper methods in application_helper.rb:
module ApplicationHelper
def find_cart
session[:cart] ||= Cart.new
end
def empty_cart
find_cart.empty!
end
def cart_empty?
return true if find_cart.empty?
end
end
Then I want to display a partial form within the layout
application.rhtml but only if the cart is not empty:
<%= render(:partial => ''...
2009 Dec 13
20
Need help...NameError in InteractController#add_to_cart
...e web development.....Each time I click my "add to cart" button" i always get the page below:I have double checked to see if i have errors in my code,there was none,please what do i need to do to proceed?
NameError in InteractController#add_to_cartundefined local variable or method `find_cart'' for #<InteractController:0x1042d0780>RAILS_ROOT: /Users/oluwayomioluwadara/Documents/CED/coursework/heritage/heritageApplication Trace | Framework Trace | Full Trace/Users/oluwayomioluwadara/Documents/CED/coursework/heritage/heritage/app/controllers/interact_controller.rb:8:in `add_...
2006 Apr 16
9
''depot'' app, where''s session?
...ontroller, and the
''Cart'' and ''Line Item'' classes. I have told Application-controller about
:cart and :line_item:
model :cart
model :line_item
Here''s part of the Store_controller:
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
#1# breakpoint "hallo"
redirect_to(:action => ''display_cart'')
end
def display_cart
@cart = find_cart
@items = @cart.items
end
private
def find_cart
#2# session[:cart] ||= Cart.new
end
#1# At this breakp...
2006 Jan 24
3
Unitialized constant
...ils, I get this error when adding a
product to my cart:
uninitialized constant Cart
...
Application Trace:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/
active_support/dependencies.rb:200:in `const_missing''
./public/../config/../app/controllers/store_controller.rb:21:in
`find_cart''
./public/../config/../app/controllers/store_controller.rb:9:in
`add_to_cart''
This error occured while loading the following files:
cart.rb
Any ideas what I did wrong? I can''t find a problem with "find_cart"
or "add_to_cart". My cart.rb class...
2008 Jul 10
5
Uninitialized constant (controller/model)
NameError in StoreController#add_to_cart
uninitialized constant StoreController::Cart
This is the controller:
class StoreController < ApplicationController
def index
@products = Product.find_products_for_sale
end
def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
end
private
def find_cart
session[:cart] ||= Cart.new
end
end
Amd this is the model
class Cart
attr_reader :items
def initialize
@items = []
end
def add_product(product)
@items << product...
2006 Apr 18
1
''depot''app, trouble with session / cookies
...-controller, and the
''Cart'' and ''Line Item'' classes. I have told Application-controller
about
:cart and :line_item:
model :cart
model :line_item
Here''s part of the Store_controller:
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
#1# breakpoint "hallo"
redirect_to(:action => ''display_cart'')
end
def display_cart
@cart = find_cart
@items = @cart.items
end
private
def find_cart
session[:cart] ||= Cart.new
end
#1# At this breakpoin...
2006 Jun 23
3
Yet another problem with NoMethodError in Store#display_cart
...;
<--- end error here --->
Here is a copy/paste of my code:
<--- file store_controller.rb begin here --->
class StoreController < ApplicationController
def index
@products = Product.salable_items
end
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
redirect_to(:action => ''display_cart'')
end
def diplay_cart
@cart = find_cart
@items = @cart.items
end
private
def find_cart
session[:cart] ||= Cart.new
end
end
<--- file store_controller.rb end here ---&g...
2006 Aug 04
6
Errors ... errors and errors.
...@products = Product.find_products_for_sale
#creates an instance variable that holds a list of all the
#products in order to make it available to the code in the view
#that will display the table
#find_products_for_sale() IS DEFINED IN product.rb
end
def add_to_cart
@cart = find_cart #we use find_cart method to find (or create)
#a cart in this session
@product = Product.find(params[:id]) #we use the params object
#to get the id parameter
#from the request and th...
2006 Feb 12
0
no method error - you have a nil object....
...alable_items function in the controller to create
a list of items that are available for sale depending on date
@products = Product.salable_items
end
def add_to_cart # method to add product with :id to the cart with
redirect to display
product = Product.find(params[:id])
@cart = find_cart # gets existing cart object or creates new one
@cart.add_product(product) # add product method sits in the Cart
class (in models)
redirect_to(:action => ''display_cart'')
end
def display_cart
@cart = find_cart
@items = @cart.items
end
private # ever...
2006 Feb 26
0
NoMethodError in Agile Web Devleopment Depot Tutorial
...in `add_to_cart''
Any ideas? Here are various bits of code:
===============================
#store_controller.rb
class StoreController < ApplicationController
def index
@products = Product.salable_items
end
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
redirect_to(:action => ''display_cart'')
end
def display_cart
@cart = find_cart
@items = @cart.items
end
private
def find_cart
session[:cart] ||= Cart.new
end
end
===============================
#cart.rb
class Cart
at...
2006 Jan 30
2
Cannot see what I have done wrong.
...= []
@total_price = 0.0
end
end
~
"app/models/cart.rb"
I have wired together the other bits in
app/controllers/store_controller.rb and app/models/line_item.rb
class StoreController < ApplicationController
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
redirect_to(:action => ''display_cart'')
end
def display_cart
@cart = find_cart
@items = @cart.items
end
def index
@products = Product.salable_items
end
private
def find_cart
session[:cart] ||= Cart.new
end
end...
2006 Jun 16
8
OffRailed, and stuck in the book : (
...e checked my store_controller.rb and it is just copied and pasted:
**********************************************************
class StoreController < ApplicationController
def index
@products = Product.find_products_for_sale
@page_title = "We Welcome you"
end
def add_to_cart
@cart = find_cart
@product = Product.find(params[:id])
@cart.add_product(@product)
end
private
def find_cart
session[:cart] ||= Cart.new
end
end
************************************************************
I''ve looked at my mySQL, and the sessions are in there.
Any insights?
Thanks a lot.
Dominic Son...
2009 Apr 24
11
We're sorry, but something went wrong.
Great. I''m in the development environment and that is the error message
I get?! What good does that do me?
I''m trying to follow along with the examples in AWDWR(3rd.), and I have
this method in a store controller:
private
def find_cart
Cart.new
end
That works fine, except that every request(initiated by clicking on an
''add to cart'' button) will cause a new cart to be created, so only the
currently selected item will be shown in the cart. Sessions to the
rescue! But when I change that method to:
privat...
2007 Oct 19
14
Agile Web Development Book, need a bit of help
I''m working my way through the book Agile Web Development with Rails,
and I am in the section where the book has me creating a display_cart
method and the associated view. When I copied the code from the book
into the view, it threw this error. If anyone could give me some hints
where I should be looking I''d appreciate it.
NoMethodError in Store#display_cart
Showing
2007 Oct 15
4
ArgumentError in StoreController#add_to_cart: wrong number of arguments (1 for 0)
...t I really don''t know what to do. I have looked up several of
topics that stated the same problem but as far as I am, nothing has
helped me out yet. Is there something wrong with the Product model?
This is in the StoreController and I believe it is all good.
def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
end
Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email...
2006 Aug 07
2
Newbie question about adding product to cart
...'m puzzled by
the code on pp. 83-84.
<%= link_to ''Add to Cart'', {:action => ''add_to_cart'', :id => product },
:class => ''addtocart'' %>
def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
redirect_to(:action => ''display_cart'')
end
In the link_to code, why isn''t :id set to product.id? In other words,
shouldn''t it be :id => product.id ?
I don''t understand why the whole product object is being...
2008 Apr 15
2
NoMethodError in StoreController#add_to_cart
...-----------------------------------------
The contents of store_controller.rb
-------------------------------------------------------------------------------
class StoreController < ApplicationController
def index
@products = Product.find_products_for_sale
end
def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
debugger
end
private
def find_cart
session[:cart] ||=Cart.new
end
end
---------------------------------------------------------------------------------
What could be the problem?
--~--~---------~--~----~----------...
2006 Feb 28
19
Session magic question
Greetings!
I could really use some help understanding what Rails puts into the session store related to the objects it creates. I''ve found documentation on how _I_ can put / get info into it, but can''t find the docs on what _Rails_ puts into it.
I''ve got a simple app that collects some data from the user, stores it in a db record, allows the user to edit it, display
2007 Aug 23
2
need help trying to debug - included screenshot
I have attached a screen shot of the error I am running into.
I am on page 138 of the Agile Web Development with Rails book by
Pragmatic Programmers.
I am developing the depot store, and I ran into an error, with
hidden_div_if.
When I remove that block of code, things to work fine, besides the fact
the cart does not display on the site, but everything else functions
correctly, so it is
2006 Apr 18
4
''depot'' tutorial failing on adding to cart
Hi
I''m very keen to learn RoR and have been following the Agile Web
Development with Rails book (first edition). However, I''ve come
across a problem which has had me stumped for days now.
After following the instructions up to page 85 I have tried testing
the code thus far, as suggested, by adding an item to the cart. But I
am getting the following error:
--