Displaying 20 results from an estimated 586 matches for "cart".
Did you mean:
card
2007 May 30
2
Depot - empty_cart with ajax
First of all id like to say hi to everyone from Argentina, im yet
another Depot first-timer.
Going through the example, i got to the point where my cart finally
runs Ajax-based. And there is a line where Dave says, after all the
job is done "You should see the cart in the sidebar update. And you
shouldn''t see your browser show any indication of reloading the page.
You''ve just created an AJAX application.". 10 seconds aft...
2006 Aug 16
2
Q on AJAX with respect to DRY
I have a shopping cart function, and I''d like to set it up to update the
cart with AJAX. My AJAX call will return a view that displays the cart
items.
My question is with regards to keeping things DRY. When the user goes to
"view cart", that page needs to display the cart, then the cart display
ne...
2009 Nov 01
5
Headache with sessions being shared.
I have a really horrendous problem with sessions.
before_filter :find_cart_from_session
private
def find_cart_from_session
if session[:cart] # if there''s is a cart in the session
begin
@cart = Cart.find(session[:cart]) # return existing or new cart
rescue ActiveRecord::RecordNotFound
@cart = Cart.create
@cart.save...
2006 Jul 28
15
Store/product stock design question
...to handle stock levels in a new
store I''m building. When products are entered into the admin of the
store, they have a stock number associated with them.
What I''m not sure about, is how I go about maintaining this stock
level. Take this scenario:
1. User A adds an item to their cart, and I check that it''s in stock -
all good.
2. User A continues to shop
3. User B adds the same item to their cart, and I check the stock
again - fine again.
4. User B checks out, pays for the item, and I decrement the stock
level for that product
5. User A is out of luck because someone h...
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture-
driven way of spec-ing or mocking. How the heck to you mock this so
the code at line (2) and (4) work right? I''m still struggling with
mocks but it seems like this can be done. Forgive the naivety of this
question.
1. def change_quantity
2. @line_item = LineItem.find_by_id(params[:id])
3. unless
2007 Feb 07
1
The Depot "Add to Cart" sessions question (2.ed agile book)
...lready know, the book goes through the regular
development cycle of the Depot application. I have hit a wall
when they started talking about the sessions and the exact mechanics of
how an item is added to the session.
The code looks like this:
depot/app/controllers/store_controller:
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
depot/app/models/cart.rb
class Cart
attr_reader :items
def initialize
@items = []
end
def add_product(product)...
2006 Feb 28
19
Session magic question
...item they get a blank form, fill it in, and save it. If they select that item again, the request gets redirected to the ''edit'' action and they get a form with the existing data displayed. I figure to check the session to see if there''s an entry for that object (like the Cart object in the Depot app) to drive the logic. I''m assuming this will work, but....
Can someone point me to some documentation on just exactly what Rails is putting into the session store, how to access it, etc?
Thanks,
Bill
-------------- next part --------------
An HTML attachment was s...
2006 Apr 16
9
''depot'' app, where''s session?
Many of you probably know the ''depot'' app from the ''Agile Rails
development'' book.
I have constructed the ''products'' model, the Store-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(pr...
2005 Nov 25
4
BlindDown recommendations?
Hi folks,
I''m putting together a site that will have a shopping cart tab along the
top which, when clicked, slides down to reveal the full contents of
the cart (covering the page underneath it).
When designing it and getting the styling right, I had the page display
the cart fully open by default. This worked fine - the cart can close
and open any number of times...
2006 Jul 31
4
RJS to find an element
I''m trying to implement a remove from cart method based on the
examples in the second edition Agile book. I have everything working
except for the RJS that removes items from the cart. Ideally what
I''d like to do is highlight an element that I am deleting only if
there is more than one of that particular item in the cart....
2006 Aug 04
6
Errors ... errors and errors.
I bought the second edition of the ruby on rails, it seems to work fine
now, did some adjustments to the code. But now I get a second error and
I want to learn to understand to fix them myself. So here is the error.
ArgumentError in StoreController#add_to_cart
wrong number of arguments (1 for 0)
#{RAILS_ROOT}/app/models/cart.rb:15:in `initialize''
#{RAILS_ROOT}/app/models/cart.rb:15:in `add_product''
#{RAILS_ROOT}/app/controllers/store_controller.rb:19:in `add_to_cart''
-e:4
Now, it says as far as I understand it, that it should...
2007 Oct 17
9
@session['user'] vs session[:user]
...[''user''] and session[:user] ? and how
would you use each?
And another question, I have the following code:
def get_customer
if @session[''customer'']
@c = Customer.find(@session[''customer''])
end
end
private
def initialize_cart
if session[:cart_id]
@cart = Cart.find(session[:cart_id])
else
@cart = Cart.create
session[:cart_id] = @cart.id
end
end
How do I assign the cart to the logged in customer?
Thanks in advance,
Elle
--~--~---------~--~----~------------~-------~--~----~...
2007 Feb 16
6
some fun functionality for all your specs
...se
end
self
end
end
end
end
end
second, I had a problem where I''d renamed some fields in the model and
didn''t want to manually spec out each method, but also didn''t want to
go the ''null object'' route. assigns[:cart] = @cart = mock("cart")
@cart.stub!(:attr_name).and_return(''cart'')
@cart.stub!(:to_param).and_return(''99'')
@cart.stub!(:class).and_return(Cart)
Cart.content_columns.each { |c|
@cart.stub!(c.name.to_sym)
}
Cart.reflect_on_...
2006 Jun 23
3
Yet another problem with NoMethodError in Store#display_cart
...ame problem as I have, but there
solutions doesn''t seems to work for me.
I''m trying to do the depot example in the AWDwR book. But now I''m stock
with a problem that I can''t solve. I get this error:
<--- begin error here --->
NoMethodError in Store#display_cart
Showing app/views/store/display_cart.rhtml where line #4 raised:
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.size
Extracted source (around line #4):
1: <h1>Display Cart</h1>
2:
3: <...
2006 Jun 16
8
OffRailed, and stuck in the book : (
...Agile w/
Rails book (latest edition) I can''t get page 115 to display.
It says:
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
Extracted source (around line #3):
1: <h1> My Agile Cart</h1>
2: <ul>
3: <% for item in @cart.items %>
4: <li><%= item.title %></li>
5: <% end %>
6: </ul>
---------------------------------------------------------------------
I''ve checked my store_controller.rb and it is just copied and paste...
2006 Jan 20
1
[protoype] Problem with Effects on draggable element if revert is true
hi,
I have a draggable element (cart-item) in a shopping cart
<%= draggable_element "item_#{product}_#{i}", :revert => true %>
When this element is dragged outside the cart into the "main_div", I want to
show a puff effect and remove the element. When it is dragged within the
cart, it should revert.
So...
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)...
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...
2005 Nov 29
6
draggable revert problem
Hello,
I have tried implementing the shopping cart ajax example and have run into
some problems. The only differences with the shopping cart is
My list of products are generated from a partial view
The images of the products come from an http link.
However, Iam seeing a strange behavior when I drag and drop the elements to
my cart. On the first d...
2007 Nov 15
7
Plain Text Stories Chaining Scenarios
I''m writing a plain text story (testing the waters) and I have
scenarios that I need to chain in my specs.
Here is what I have so far:
Story: User purchasing tshirts
As a user
I want to checkout
So that I can purchase shirts
Scenario: User goes to checkout with nothing in cart
Given a user
And user has an empty cart
When user goes to checkout
Then user should see the page: site index
And page should include the text: you have nothing in your cart
Scenario: Logged-in user goes to checkout
Given a logged-in user
And user has a cart wi...