similar to: Nested hash from form params into create()?

Displaying 20 results from an estimated 900 matches similar to: "Nested hash from form params into create()?"

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 %> &times; <%= h(cart_item.title) %> I did some research, and I can grasp that local
2005 Dec 21
2
ActiveRecord Error with << in Collection
Hi I get a following error: ActiveRecord::AssociationTypeMismatch in Cmdb#create ConfigurationItemAttributeValue expected, got Array RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations/association_collection.rb:128:in `raise_on_type_mismatch''
2006 Apr 04
1
habtm and options_from_collection_for_select [1.0.0]
I ran into a problem using options_from_collection_for_select : ActiveRecord::AssociationTypeMismatch (Topic expected, got String): /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/ active_record/associations/association_collection.rb:128:in `raise_on_type_mismatch'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
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 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
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 =>
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
2010 Sep 01
0
Error on update_attributes with HABTM relationship
Hope someone can tell me what''s up, because this has me baffled. I have an Image model, and a Provider model. Both are defined as "has_and_belongs_to_many" relating to each other. In my image form partial, I have a bit of AJAX generating the provider_ids array dynamically from a provider AJAX search on the same page. So for example, each time I click on a provider name that
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
2008 May 12
3
Enumeration sum
Any idees why I can do this: @sum = @selected.inject(0) { |sum, player| sum + player.value } but not this: @sum = @selected.sum { |player| player.value } @sum = @selected.sum(&:value) The last two give me following error: wrong number of arguments (1 for 2) /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_collection.rb:164:in `calculate''
2006 Mar 22
2
What is wrong in this method??????
Hi, This is my definition of method "add_to_cart" ======================= def add_to_cart count=params[:product][:count] while count.to_i>=0.to_i if params[:product][''dem_quantity''+count.to_s]=="" else @product = Product.find(params[:product][''product_id''+count.to_s]) print @product.name
2006 Jan 23
0
type mismatch because of misled array index
Most times I look up a list of books I want to know a page reference for each one, so the views that display booklists expect an array of two-element arrays, constructed via a method in the model like so: (class Category) def book @book = Array.new self.bookshelves.each { |x| @book << [x.book, x.pages] } return @book end When I get the list of all books that a user has
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?
2010 Oct 11
8
Nooby Stuck - "has_and_belongs_to_many" relationship
trying to set up a "has_and_belongs_to_many" relationship would very much appreciate the help, not sure what im doing wrong at all. Scheme.rb class Scheme < ActiveRecord::Base validates :schemename, :presence => true belongs_to :user has_many :levels, :dependent => :destroy has_and_belongs_to_many :works end Work.rb class Work < ActiveRecord::Base
2007 Jun 01
0
"Exception: stack level too deep" on collection.clear?
Without getting too deep into my app I''m wondering if anyone has any clues what might give rise to the error posted below. It occurs when I run my unit tests. class Actor < AR:Base belongs_to :court_case end class CaseCause < AR:Base belongs_to :court_case end class CourtCase < AR:Base has_many :actors has_many :case_causes ... end def my_test_method ...
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 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 23
3
has_and_belongs_to_many and dynamic find
Hi Just curious if anyone can explain why using a dynamic find fails to work with << operator I have standard habtm relationship class User < ActiveRecord::Base has_and_belongs_to_many :roles Now when I assign a Role via << after saving the new User I get wierd behaviour but only when using the dynamic version of find i.e @user = User.new(p) if @user.save #
2006 Jan 22
2
acts_as_taggable: weird SQL problem with untagging
Setup as follows: class Resource < ActiveRecord::Base belongs_to :user validates_presence_of :filename validates_uniqueness_of :filename, :scope => "user_id", :message => "already exists, try uploading another file or deleting first." acts_as_taggable :join_class_name => ''TagResource''