search for: line_items

Displaying 20 results from an estimated 93 matches for "line_items".

Did you mean: line_item
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 Nov 20
3
How to test views with Nested Resources and Partials
Hi everyone, I am relatively new to rspec and I am running into a wall in testing my views. I have a RESTful resource Contracts with a nested resource of Line_items. I am trying to figure out how to test the "edit" form of the Line_items. What complicates this is the nested routing and how to account for it, and that there is a partial form (_form.haml) that both the edit.haml and new.haml views use (app/views/line_items). My spec keeps failing and...
2006 Jul 08
4
Hidden fields in forms
Please can someone show me the correct syntax for a hidden field in forms, this is my code <%= start_form_tag :action => ''create'' %> <div class="form1"> <table width="auto" boader="8" cellspacing="5" cellpadding="5"> <% hidden_field ''line_item'', ''client_id'', :value
2006 Feb 24
7
One To Many To Many
Hey all, I''m trying to find a simple way to reference all of the objects that belong to their parent''s parent. In other words: Clients --> Orders --> LineItems How do I get all of a client''s lineitems in one array (i.e., client.all_lineitems)? Thanks! -Neal -- Posted via http://www.ruby-forum.com/.
2006 Oct 13
3
How to get a count of line_items
I am fairly new to Rails, and I am having difficulty in forgetting the old way of developing and using the Rails way. This is my question, using orders and line_items as an example. An order has_many line_items A line_item belongs to order In my OrdersController I have def summary @orders = Orders.find(:all) render :xml => @orders.to_xml() end What I want to achieve is to include a count of line_items per order, and to include it as say total_...
2006 Feb 16
9
association not inserted automatically.
Hello, I am trying to write a sample application. I have class LineItem< ActiveRecord::Base belongs_to : order end && class Order < ActiveRecord::Base has_one :line_item end Now in the controller i am trying : def add @ord = Order.new(params[:ord]) @ord.line_item = LineItem.new(params[:lineitem]) if @ord.save redirect_to :action => ''list'' else render
2006 Jul 30
1
Insert multiple new child records with the parent
...9;'}, {''description'' => ''line b'', ''cost'' => ''200''}]. I can''t find the correct naming convention for the textboxes to produce this data structure in the controller. I have tried: <%= text_field_tag("line_items[0][description]") %> <%= text_field_tag("line_items[0][cost]") %> <%= text_field_tag("line_items[1][description]") %> <%= text_field_tag("line_items[1][cost]") %> which results in a hash of hashes: "invoice_default"=>{"0&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. Presuma...
2013 Sep 23
1
redirect on browser success, but redirect on functional test is error
line_items.yml: one: product_id: 1 cart_id: 1 quantity: 1 carts.yml: one: {} product.rb: has_many :line_items cart.rb: has_many :line_items, dependent: :destroy line_item.rb: belongs_to :product belongs_to :cart line_item_controller.rb: def destroy @line_item = LineItem.find(params[:id]) @c...
2006 Jan 24
3
Is there a concise way?
Hi, Is there a concise/ruby way to do the following: [Note: 1 and 2 below are not related.] (1) for p in 0...@order.line_items[k].shipment_lines.length shipline_qty = shipline_qty + @order.line_items[k].shipment_lines[p].quantity end (2) ts = Array.new for tk in s.trackings ts.push(tk) end Thanks.
2006 Jun 24
2
Migrations problem with Agile Rails book
I am following the instructions on Agile Web Development 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_prod...
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 helper methods in application_helpe...
2006 Jul 20
1
Having issues saving line items to the DB
...pefully someone on this list can shine some light on my problem, or point me in the right direction. Thanks! Nick Ciske Environment ------------------------ Rails 1.1.3 Windows XP/WebBrick SQL Server Express 2005 Code ------------------------ Models: Project has_many :quotes Quote has_many :line_items LineItem belongs_to :quote ... @project = Project.new(params[:project]) @quote=Quote.new(params[:quote]) @line_items=[] if params[:line_item1][''quantity_id''] != '''' @line_items << LineItem.new(params[:line_item1]) end if params[:line_item2][''...
2006 Feb 05
8
Agile Rails book: depot problem
...(I can only creat and update them). When I try to delete a product --> http://localhost:3001/admin/destroy/3 I get this error message: ActiveRecord::StatementInvalid in Admin#destroy Mysql::Error: #23000Cannot delete or update a parent row: a foreign key constraint fails (`depot_development/line_items`, CONSTRAINT `fk_items_product` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`)): DELETE FROM products WHERE id = 3 Can someone explain me what''s going wrong? I''m not a MySQL expert... Before I started to use Rails, I didn''t even know...
2006 Jan 12
5
Question about using DISTINCT in ActiveRecord find method.
Hi, Am relatively new to the RoR world. My question is quite simple. I have a query like such: shipmentNumbers = Order.find_by_sql(["select distinct s.id from orders o, line_items li, shipment_lines sl, shipments s where o.number=? and o.id = li.order_id and li.id = sl.line_item_id and sl.shipment_id = s.id", number]) The above query works fine. I wanted to do the same query using the query below: shipmentNumbers = Order.find(:all, :conditions => ["number...
2006 Jun 02
0
Problem updating child row from parent model
I developped a web site with Ruby on Rails, but I get a problem during the testing. I have a parent table called "orders" and a child table called "line_items". I created some data for the test in the files "test/fixtures/orders.yml" and "test/fixtures/line_items.yml". In the file "test/unit/order_test.rb" I wrote some code to test the "Add", "Update" and "Destroy" for my model"Order...
2006 Jul 01
3
best approach to add form elements dynamically
I am struggling with how to add dynamically add form elements to a form based on user action. Now here is my situation: I have model Project that has_many line_items On the form to create a project I initially display form elements (some drop downs and text boxes) for adding just one line_item. There is also a button or a link on the page (not sure if this should be in the main form or outside). One the user selects that button/link I need to add another s...
2006 Apr 11
5
multiple select_tag
Hello again, I have a table called line_items, with the following fields: id int item_name varchar() qty int conditions text I''ve made my LineItem model, and everything works as such (with simple text_fields).. Now I''d like for the conditions field to be a select_tag() with multiple choice possibility. I''m guess...
2006 May 02
4
Bug in rails ?
...mple question. I am writing an app using rails to familiarize myself with the framework (which is pretty cool, by the way). I just wanted to know why these two work differently (since "find" should be a synonym for "detect" according to the Pick Axe) : current_item = @invoice.line_items.detect {|i| i.product.id == key} current_item = @invoice.line_items.find {|i| i.product.id == key} (The details of my project are irrelevant, I think.) The first one works, the second doesn''t. With the "find" variant, I get this error : "Couldn''t find LineItem wi...
2011 Aug 02
1
NoMethodError in Store#index
Thanks in advance I want to know how to solve No method errors Agile Rails 4th ed Great book But second time I get this type of error I would like to know how to troubleshoot and resolve Please see below thanks once again NoMethodError in Store#index Showing C:/rails/shop9/app/views/line_items/_line_item.html.erb where line #9 raised: undefined method `title'' for nil:NilClass Extracted source (around line #9): 6: <% end %> 8: <td><%= line_item.quantity %>&times;</td> 9: <td><%= line_item.product.title %></td> 10: <td cla...