search for: cartitem

Displaying 18 results from an estimated 18 matches for "cartitem".

Did you mean: cart_item
2006 Jul 24
1
Newbie error: undefined local variable or method
...can grasp that local variables aren''t accessible here, but I''m not sure how to troubleshoot and find where the problem occurs. (I''m coming from php and coldfusion, so maybe my head is warped in the wrong direction.) One thing that throws me is that cart_item is a class (CartItem), not a var or a method...??? Code included below for reference. The code starts with the Store controller: def add_to_cart @cart = find_cart @product = Product.find(params[:id]) @cart.add_product(@product) end The add_product method is in the Cart model: class Cart...
2006 Jun 26
5
Newbie question about Agile Rails book - Delete from cart
I have been working through the Agile Web Development with Rails book doing the Depot tutorial. I have completed it and it works but I cant say I understand how and why. My question is this "After adding products to the Cart, how do I then give users the option to delete just one item and not empty the whole cart?" I''ve been playing around with all sorts of code, just making
2007 Jun 06
0
uninitialized constant Cart::CartItem
I am following a tutorial and get thar error creating a cart, and can''t figure it out, uninitialized constant Cart::CartItem Extracted source (around line #8): 5: <h3>Your Shopping Cart</h3> 6: 7: <ul> 8: <% for item in @cart.cart_items %> 9: <li id="cart_item_<%= item.book.id %>"> 10: <%= render :partial => "cart/item", :object => item %> 11:...
2006 Aug 18
0
AJAX question
Dear all, Help me get a simple AJAX behavior right. I know zero AJAX, thus please advice. Below is a simplification of the real code and I hope I can describe my intention clearly. class StoreController < ApplicationController def show_cart @cart = Cart.new @new_item = CartItem.new end def add_item @new_item = CartItem.new(params[:new_item]) if @new_item.valid? @cart.items << @new_item # execute add_item.rjs else breakpoint render :partial => ''new_item'' end end end app/views/store/show_c...
2006 Aug 18
0
Simple AJAX question
Dear all, Help me get a simple AJAX behavior right. I know zero AJAX, thus please advice. Below is a simplification of the real code and I hope I can describe my intention clearly. class StoreController < ApplicationController def show_cart @cart = Cart.new @new_item = CartItem.new end def add_item @new_item = CartItem.new(params[:new_item]) if @new_item.valid? @cart.items << @new_item # execute add_item.rjs else breakpoint render :partial => ''new_item'' end end end app/views/store/show_cart.rhtml...
2006 Jul 10
2
cross controller functional tests?
...which involves several controllers? How can I write a test that calls actions from different controllers in a particular sequence? Something like the following which involves department, product, cart_item, and cart controllers. get department 5 check it has a link to product 4 get product 4 post cartitem/create get cart see that product 4 in in the cart Thanks, Peter
2006 Aug 04
6
Errors ... errors and errors.
...@items = [] end def add_product(product) existing_product = @items.find {|item| item.product == product} if existing_product existing_product.increment_quantity else @items << Cart.new(product) end end end [CODE] And here is the cart_item.rb [CODE] class CartItem include Reloadable attr_reader :product, :quantity def initialize(product) @product = product @quantity = 1 end def increment_quantity @quantity += 1 end def title @product.title end def price @product.price * @quantity end end [CODE] -- Posted via htt...
2006 Jun 08
19
Agile Web Dev (book) question: errors
This is kind of frustrating (but no doubt helpful in the long run) that after following along and coding , and d/l the code the same error is appearing. For those who are familiar with the depot app, I''ve run into a problem after fixing the cart to reflect quanitites. I worked through the intended error messages but now have this appearing: SyntaxError in StoreController#add_to_cart
2006 May 06
3
Tip, may even be useful
Here''s something that caused me a couple of hours of head-scratching today: Apparently, if your model doesn''t derive from ActiveRecord, it is NOT reloaded for each operation in the development environment. I was working with something that uses a single model per session, and stores its data in the session. I kept wondering why I didn''t see my changes. Finally, I
2006 Feb 27
1
Nested hash from form params into create()?
...tions"=>{"6"=>{"option_id"=>"74"}, "7"=>{"option_id"=>"97"}, "5"=>{"option_id"=>"47"}} } ## CONTROLLER ## def add_to_cart CartItem.create(params} end ## MODELS ## class CartItem < ActiveRecord::Base belongs_to :variation has_many :cart_item_options end class CartItemOption < ActiveRecord::Base belongs_to :cart_item end ## TABLES ## CREATE TABLE cart_items ( id SERIAL, variation_id INTEGER UNSIGNED NOT NU...
2007 Oct 15
4
ArgumentError in StoreController#add_to_cart: wrong number of arguments (1 for 0)
I am really new to Ruby and Rails but as you probably see I am trying to get the shopping card working from the book. I am getting this error but 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
2009 Jun 17
2
validates_uniqueness_of fails on STI in Rails 2.3.2
I''ve got something like this: class Position < ActiveRecord::Base end class CartItem < Position validates_uniqueness_of :product_id end When I try to save CartItem I get this error: ArgumentError: wrong number of arguments (1 for 2) from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:758:in `exists?'' from /home/joaz/.gem/ruby...
2007 Oct 18
0
REST help
Hi all, I am trying to build a RESTful shopping cart and I have hit a small wall, but before I get to that let me explain what I have done thus far. I have two RESTful controllers, CartController and CartItemsController with a nested routes setup like so map.resources :carts do |carts| carts.resources :cart_items, :collection => {:empty => :delete} end (I added a custom route to the for emptying the cart as it seemed to me that when I clear the cart I am operating on the items which is w...
2005 Oct 15
1
uninitialized constant errors?
Running with WEBrick, I seem to be occasionally getting these odd "uninitialized constant XXX" errors. Where the XXX is the first class that whatever action I run uses (e.g. Product, CartItem etc). >From the backtrace, it looks almost like the server is somehow trying to reinitialize? Any thoughts? /usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in `const_missing'' app/controllers/store_controller.rb:53:in `index'' /usr/lib/r...
2006 Jul 18
15
Agile Web Developement with Rails
I recently got a copy of the second addition in PDF and got stuck on the Ajax portion using highlighting page 128. While trying to make my cart flash I got an RJS error when I click add to cart. I have gone back and made sure my code matched what was in the book but no help. I sent Dave an email and he rec''d this list. Anybody got any good links for troubleshooting Ajax or maybe have see
2006 Jul 03
0
Page 129 of Agile Web Dev on Rails (or pg141 of pdf!)
...lor":"#88ff88", "endcolor":"#114411"}); Code in cart.rb: # add a product to the cart def add_product(product) current_item = @items.find {|item| item.product == product} if current_item current_item.increment_quantity else current_item = CartItem.new(product) @items << current_item end current_item end Code in storecontroller.rb: # add a product to the cart def add_to_cart begin @product = Product.find(params[:id]) rescue logger.error("Attempt to access invalid product #{params[:id]}")...
2007 Sep 14
0
deal with Controller and Action logic in RJS?
...nd then we will render the cart again so that the line will disappear. Then we actually first have to decrement the quantity from 1 to 0, then use the RJS file to draw the cart, and highlight the line (flashing its color), and then again in the RJS file, deal with the Action logic to remove the CartItem from Cart (possible by calling a method in the StoreController class) and then redraw the cart again? This is somewhat spaghetti like... is it that in MVC 1, the Action mixes with view logic and it is better for AJAX, but for MVC 2, the Action is separate from the View, so AJAX will be done by...
2006 Jul 16
17
AWDWR question
In an early section on Action View, showing code being put directly into the rhtml file: <% require ''date'' DAY_NAMES = %w{ Sunday Monday Tuesday Wednesday Thursday Friday Saturday } today = Date.today %> <h1>Hello, Dave</h1> <p> It''s <%= DAY_NAMES[today.wday] %>. Tomorrow is <%= DAY_NAMES[(today + 1).wday %>. </p> I get this