Displaying 20 results from an estimated 3000 matches similar to: "There is Something wrong with the div..."
2006 Jul 26
1
Something is wrong with this peice of code...
<% if @cart.items.empty? %>
|^|^|^|^|^|^|^|^|^|^|^|^|^|
This peice of code is having a problem in the store.rhtml of my
application but i have no idea why... it says that it is and (extracted
source... here is the Store.rhtml... this is from an application made in
"Ruby on Rails" and it wont tell me how to fix it... iv done everything
in the book the exact way its told me,
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
2008 Jul 14
1
question about method "hidden_div_if" in AWDR 2
I followed the sample code in AWDR 2 like this:
store_helper.rb
def hidden_div_if(conditions, attributes = {})
if conditions
attributes["style"] = "display:none"
else
attr = tag_options(attributes.stringify_keys)
"<div #{attr}>"
end
end
store.html.erb
<%= hidden_div_if(@cart.items.empty?, :id => "cart") %>
<%=
2006 Jul 26
0
Something wrong with the div
<div id="side">
<div id= "cart"
line 16----> <% if @cart.items.empty? %>
style="display: none"
<% end %>
<%= hidden_div_if(@cart.items.empty?, :id => "cart") %>
Whenever i press on checkout it says....You have a nil object when you
didn''t expect it!
The error occured while evaluating nil.items,
2007 Mar 23
1
How does this helper work? (agile book)
Hello,
Im trying to understand how this helper method works:
def hidden_div_if(condition, attributes = {})
if condition
attributes["style"] = "display: none"
end
attrs = tag_options(attributes.stringify_keys)
"<div #{attrs}>"
end
This is how they are calling it:
<%= hidden_div_if(@cart.items.empty?, :id => "cart") %>
2006 Jul 13
1
From the Agile book, page 144 regarding a div tag helper
Hi. in the Rails Agile book here''s what was happening:
>>>
module StoreHelper
def hidden_div_if(condition, attributes = {})
if condition
attributes["style" ] = "display: none"
end
attrs = tag_options(attributes.stringify_keys)
"<div #{attrs}>"
end
# format_price method ...
end
Note that we cheated slightly here. We copied code from the Rails
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
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
session[:cart] = @cart.id
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
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
needs to update with AJAX calls when items are added from that page. It
would
2007 Feb 07
1
The Depot "Add to Cart" sessions question (2.ed agile book)
Hello,
Im in the process of working my way through the 2.ed of the agile book.
As many of you already 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
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
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
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 without problem[1].
2007 Feb 16
6
some fun functionality for all your specs
I''ve found these two snippets of code useful and would love some feedback.
first, .should_have_valid_associations
usage:
context "A new Product" do
specify "should have valid associations" do
@product.should_have_valid_associations
end
end
code: (thanks to Wilson/Defiler for converting to rspec)
module Spec
module Expectations
module Should
2006 Jun 23
3
Yet another problem with NoMethodError in Store#display_cart
Hi everybody,
I''ve search a lot on google to help me with this one without success. I
know that some people had the same 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 --->
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 i wrote this code for drop_receiving _element
<%=
2006 Sep 03
2
Undefined method "xxx" of a model when calling a helper
Hi all
I''m creating a shop page. I have a cart model that looks like the
following:
class Cart
attr_reader :line_items
def get_line_item id
@line_items.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
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] ||=
2006 Jun 16
8
OffRailed, and stuck in the book : (
Help, i''ve been trapped on the tracks here for a day now in the 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: