search for: product_id

Displaying 20 results from an estimated 180 matches for "product_id".

2006 Jul 13
8
can''t convert true into integer
I have a method: ? def reduceProuctInventoryBy(product_id, reduction) ? ? t=Product.find(:first, :conditions =>["id = ?", product_id]) ? ? t.qty=(t.qty-reduction) ? ? t.save ? end and the model: class Product < ActiveRecord::Base ? validates_presence_of :qty, :specialDescription ? validates_numericality_of :qty end but when i run my met...
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t spec it, see this pastie: http://pastie.caboo.se/53120. When following the link from a browser I''m being redirected to the right page. -------------- next part -------------- An HTML attachment was scrubbed... URL:
2006 Jan 05
2
Agile Depot Tutorial Help
anyone can explain me why in the Agile Depot Tutorial application they use i.product_id to find if a product already exist in the cart, because the cart contains items, each of them references a product. I tried i.product_id like in the tutorial and i.product.i all of these 2 notation works , but i find the second seems more clean??? isn''t it. Any explanation will be fine...
2006 Jul 13
1
error_messages_for
...validate a few fields some1 please help me out model--------- class Record < ActiveRecord::Base validates_presence_of :sw, :flex end controller------------ class RecordController < A;;icationController def new @record = Rrecord.new @product = Product.find(params[''product_id'']) end def create @Record.new(params[''record'']) if @record.valid? @record.save redirect_to :action => ''show'', :id = @record.product_id else render_action ''new'' end end end...
2006 May 04
2
Building a FAQ
...s about each product) and category (questions of different categories or topics), and there is something I can''t figure it out how to do. I have these tables: create_table "faqs" do |t| t.column "question", :text t.column "answer", :text t.column "product_id", :integer t.column "category_id", :integer t.column "position", :integer end create_table "products" do |t| t.column "name", :string t.column "description", :text end create_table "categories" do |t| t.column "name&quo...
2006 Jan 15
6
Saving one-many associations (elegant solution please)
What is the most elegant way to save new one-many associations? order = Order.new(:name => "My Order") order.line_items << LineItem.new(:product_id => 1, :quantity => 2) order.line_items << LineItem.new(:product_id => 2, :quantity => 5) order.save The above - which is by far the most elegant way of putting it - doesn''t work for me - the line_items don''t get saved. Presumably because the order does not ha...
2009 Feb 18
3
wrong number of arguments (1 for 0)
...ace | Framework Trace | Full Trace app/controllers/customer_controller.rb:36:in `session'' app/controllers/customer_controller.rb:36:in `add_to_cart'' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ My controller is ... def add_to_cart if request.post? product_id = params[:product_id] quantity = params[:quantity] account = get_account() error)---> session[:cart] = SessionCart.new(account) if session(:cart).nil? session[:cart].add_product( product_id) if quantity >= 2 and quantity <= 50 for i in 1..quantity-1...
2006 Jan 06
6
HABTM problem not saving all associations
...TM association declared in the model will save during the initial @order.save in the create action in my orders_controller.rb code below. If the order is then updated via an edit action, all selected associations will save correctly. If you notice in the development.log dump, I''m passing product_ids and loan_type_ids arrays back to the controller properly. Inspecting the @order object during a breakpointer session shows the related object are available for saving, but for some reason, ActiveRecord does not want to save the second association class at the beginning. Any ideas what I''...
2006 May 19
7
How can I set up relations for these models?
Hello! I have a legacy DB and want to use ActiveRecord for it. However, I can''t set up a relation correctly. Here''s table spec: [products] id name price [subproducts] product_id subproduct_id Some example data: [products] 1, "Computer", 500.00 2, "Monitor", 200.00 3, "Printer", 100.00 4, "System", 700.00 5, "System2", 650.00 "System" is made up of "Computer", "Monitor", and "Printer&qu...
2011 Sep 07
4
jquery and ajax query in rails 3
hi people I don''t know much about ajax - jquery. And right now I need to use some functionality with them. In a form (sales model) I have the following code: <div> <%= f.label :product_id, "Product" %> <%= f.collection_select( :product_id, Product.all, :id, :name, options={} ) %> </div> <div> <%= f.label :price, "Price" %> <%= f.text_field :price %> </div> The idea is: when I select a "product" I...
2009 Feb 12
4
routes
I''m trying to figure this. in my schools controller i want to do this.... # implement a create action to create just the review for the School... def create_review_for_a_school @review = Review.new @school = School.find(params[:school_id]) @review = @school.reviews.build(params[:review]) if @review.save # The creation worked....do this flash[:notice] =
2006 Mar 14
5
GROUP BY and SUM
..., order_items, and products. I want to collate several orders so that I can get a SUM of quantities ordered for each product etc. Can I say something like (the below gives an error on :sum, and ignores :group) OrderItem.find(:all, :sum => ''quantity'', :group => ''product_id'', :include => [:order, :product]) I want to get back a collection of order_items, GROUPed BY product_id. It is important for me to get back order_items, as then I can get to the product using the belongs_to association to get the name of the product, plus the business rules to calc...
2006 Aug 15
3
update or alter cart
I want to modify and update the items in the Depot - "display_cart". Since the cart is in a session, its a little hard to get at the data. I just want to create a way to change quantities, prices and recalculate. Has someone done this, and could you point me to the right direction. Thanks Chas -- Posted via http://www.ruby-forum.com/.
2006 Jun 05
5
adding habtm through migrations
...not know how to set the primary key in the categories_products table. this is what I''ve got in my migration file: create_table :categories do |t| t.column :name, :string # Other fields here end create_table :categories_products do |t| t.column :category_id, :integer t.column :product_id, :integer #how do I set the primary key to be (category_id, product_id) end Cheers Regards srdjan
2006 Jun 24
2
Migrations problem with Agile Rails book
...pment with Rails book "Iteratio E1: Capturing an Order" section. When I run the migrations I get the following error. rake db:migrate (in /Users/balaparanj/work/depot) -- execute("alter table line_items \n add constraint fk_line_item_products \n foreign key (product_id) references products(id)") rake aborted! Mysql::Error: Table ''depot_development.line_items'' doesn''t exist: alter table line_items add constraint fk_line_item_products foreign key (product_id) references products(id) (See full trace by runni...
2005 Dec 19
2
Difficulty using correct moldel for the data in DB
..., `cat_id` INTEGER(11), `rank` INTEGER , PRIMARY KEY(`id`) ); CREATE TABLE `cats` ( `id` INTEGER(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255), PRIMARY KEY(`id`) ); CREATE TABLE `fusions` ( `id` INTEGER(11) NOT NULL AUTO_INCREMENT, `item1_id` INTEGER(11), `item2_id` INTEGER(11) , `product_id` INTEGER(11), PRIMARY KEY(`id`) ); Now... Creating one-to-many relationship for item/category is cake. How do I set up my model for item and fusion so I can have something like below in my view? <% for fusion in @item.fusions %> <%= fusion.item1.name %> + <%= fusion.item2.name %&...
2006 Jul 11
7
Rails associations: Easy Question requires dumb answer
...is my controller code: /snip t=Product.create(:specialDescription=>"Cleans shit",:qty=>12) t.template=Template.find(:first) t.save My intention is to have several Products reference one template. But when I execute the above snip, I get this: Unknown column ''templates.product_id'' in ''where clause'': SELECT * FROM templates WHERE (templates.product_id = 1) Heres the dumb question: Why didn''t that work? Obviously rails is looking in templates for a productid, but I told it the exact opposite, that a product has a templateid. WTF MATE?...
2006 Mar 21
11
Stuck on ActiveRecord
...I''m having great fun developing with Rails but I''ve come to a problem that I can''t quite figure out. I have an Order object that "has_many" order_lines. This works perfectly and I can see all the lines. The OrderLine object has an order_id field as well as product_id and amount. Now ideally I would want to do : order.orderline[0].product.name for example to pull back the name of the product it''s linking to - but no matter what I try, I cannot get that to work. Can anyone tell what I''m doing wrong? I imagine it''s pretty obvious......
2005 Oct 05
3
Shopping Cart: SKU and Product Confusion
...lient were not specific to the combination each product offers. So, the related DB tables were essentially this: Table Products: =========== id | sku | title | price | etc... Table Colors: ========= id | color Table Sizes: ========= id | sizes Table Colors_Products: ================= color_id | product_id Table Products_Sizes: ================ product_id | size_id Everything was fine and dandy until I got to the point where I wanted each combination of a product to appear as a separate line item in the shopping cart (the natural way to display items). There was no way for me to determine the uniqu...
2006 Mar 03
7
Meta Programming Help
I have the following two methods: def ProductFile::find_images(mode, prod_id) # convert to symbol in case it is not (most commonly it may be a String) mode = mode.to_sym case mode when :all, :first ProductFile::find(mode, :conditions => ["product_id = ? AND file_type LIKE ?", prod_id, "image%"]) end end def ProductFile::find_documents(mode, prod_id) mode = mode.to_sym case mode when :all, :first ProductFile::find(mode, :conditions => ["product_id = ? AND (file_type LIKE ? or file_type LIKE ?)&qu...