Displaying 20 results from an estimated 7000 matches similar to: "deal with Controller and Action logic in RJS?"
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
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?
2006 Jul 03
0
Page 129 of Agile Web Dev on Rails (or pg141 of pdf!)
Hi - another question, sorry....
I''m trying to get the highlighting effect to work on the current_item.
The page refreshes fine, and then I get an error as the highlighting
code is fired:
page[:current_item].visual_effect :highlight,
:startcolor => "#88ff88",
:endcolor => "#114411"
The error
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
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
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
2006 Jul 24
1
Newbie error: undefined local variable or method
When I add an item to the shopping cart, I get an error:
undefined local variable or method `cart_item'' for
#<#<Class:0x3715a78>:0x3715a48>
Session info says the cart being updated properly. I''m just not able
to output two variables:
<%= cart_item.quantity %> × <%= h(cart_item.title) %>
I did some research, and I can grasp that local
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 Apr 20
0
problem in "depot" app - cart contents not shown on checkout
Hi all -
I''m working my way through the "depot" tutorial. I''m having a problem
with the section where the cart contents are displayed on the order
page. The cart contents display fine after I add an item to the cart,
but simply does not show up on the order page.
Any help would be appreciated.
I''m running Locomotive 1.0.0c on Tiger with MySQL from
2008 Apr 15
2
NoMethodError in StoreController#add_to_cart
I''m trying to set up the Depot app from Agile Web Development and I
got this error after C1 - Creating a Cart.
The exact error looks like this:
-------------------------------------------------------------------
NoMethodError in StoreController#add_to_cart
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while
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
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 =>
2006 May 25
2
Newbie AJAX rjs syntax question
I''m brand new to Ruby and to Rails, and I''m running through Pragmatic''s
"Agile Development" V.2 book and am having problems with the rjs files
in their tutorial.
First problem:
page[:cart].replace_html :partial => ''cart'', :object => @cart
This line stopped the AJAX request. The action completed without
trouble, but when it hit
2006 Jul 03
2
Agile Web Dev on Rails - ActiveRecord::RecordNotFound Prob
Hi there
I''ve also made a start on the Agile Web Dev using Rails book! I''ve been
hit with a problem when hitting the ''Add to Cart'' button - I get the
following error message:
ActiveRecord::RecordNotFound in StoreController#add_to_cart
Couldn''t find Product without an ID
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full
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. If the
item deleted is the only of
2006 Jul 10
2
cross controller functional tests?
Hi,
I have an online store and I would like to simulate a complete
shopping trip 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
2006 Feb 12
0
no method error - you have a nil object....
hi,
i''ve been cracking my head on this one for a while and would be humbly
grateful for any pointers
i''m working through Agile Web Devopment w Rails and, in the depot
example have created the cart class for session handling, but am getting
the following error, which suggests the @items variable is not being
populated with any data from LineItem
NoMethodError (You have a
2006 Jan 30
2
Cannot see what I have done wrong.
In the Agile Rails tutorial I am revisiting building a cart. I have
followed the steps given in the book to create the class ''Cart''
thus:
class Cart
attr_reader :items
attr_reader :total_price
def add_product(product)
@items << LineItem.for_product(product)
@total_price += product.price
end
def initialize
@items = []
@total_price = 0.0
end
2008 Sep 03
2
Highlighint rjs problem on a new product
Hi,
Problem Summary:
I have been trying to add the highlight effect to my table but
everytime a new record is added the highlighting gives an rjs error.
However when i click the add to cart button on a product that already
exists inside the table, the highlight effect works. Is this because
the partial must only have only one <tr></tr> in it and the <table>
must be on the other
2006 Feb 26
0
NoMethodError in Agile Web Devleopment Depot Tutorial
I''m working on building the shopping cart in the Depot tutorial in the
Agile Web Development book. I''m at the part (about page 80) where you
build the ability to add items to the cart. I''m able to get to
/store/display_cart/ and it seems items are being added, but if I just
click on a link to add an item (/store/add_to_cart/2) it gives me this:
NoMethodError in