search for: unit_price

Displaying 20 results from an estimated 30 matches for "unit_price".

2006 Sep 28
15
Inserting rows into linking table
Hi, I have two objects: Contacts Lists I want to be able to add multiple contacts to multiple lists. I''ve created a linking table and a form that allows me to select the contacts using checkboxes, but I''m having some problems with the controller and model. I receive the following error message when I submit the form: Mysql::Error: Cannot add or update a child row: a
2005 Dec 14
9
Passing quantity in a shopping cart
I am using this line on my index.rhtml page to capture the quantity required of a particular item for a basic shopping cart app: <%= text_field ''line_item'', ''quantity'', {:size=>3} %> </td> but my next screen (a cart screen) doesn''t reflect what was entered in that text field when the item is added to the cart. That is,
2006 Apr 24
3
Form with multiple rows of content
...'s the rhtml code: <%= start_form_tag :action => ''update_cart'' %> <% for @item in @items %> <%= @item.product.title %> <%= text_field "item[]",''quantity'' %> <%= number_to_currency(@item.unit_price) %> $<%= @item.quantity * @item.unit_price %> <%= link_to ''Remove item'', {:action => ''remove_from_cart'', :id => @item.product} %> <% end %> Total $ <%= @cart.total_price %> <%= submit_tag '...
2006 Jul 15
0
Validate using boolean values
The Problem: how to do the validation. I have not written it correctly!!! Given two tables: sizes and prices; with a relation: has_many ,belongs_to a Price.unit_price for a given Size.meassure must be marked ''true'' as the standard unit_price for that meassure. There will be many other unit_prices for a given meassure, those must be marked ''false'' table sizes meassure, :string (ie.small, medium, big) Model Size has_many :pr...
2006 Mar 01
2
active_record postgresql adapter problem
Instead of using numeric I created the field "unit_price" as PostgreSQL type money. Now when I try and add a row I get the following. How do I override AR default behaviour to cast numeric post data to money, or am I forced to only support database types that active_record knows about? RuntimeError: ERROR C42804 Mcolumn "unit_price"...
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 Jul 08
4
Hidden fields in forms
...t;description" >Description :</label></td><td><%= text_area ''line_item'', ''description'', :cols=>"99", :rows=>"2" %></td></tr> <tr><td><class="depot-form" label for="unit_price" >Price :</label></td><td><%= text_field ''line_item'', ''unit_price'' %></td></tr> <tr><td></td></tr> </table> </div> <%= submit_tag ''Create Additional Item'' %>...
2007 Aug 30
3
Rails - depot application
...0: -%> 11: <tr> 12: <td><%= item.product%></td>" this is display_cart.rhtml line_item.rb has: "class LineItem < ActiveRecord::Base belongs_to :product def self.for_product(product) item = self.new item.quantity = 1 item.product = product item.unit_price = product.price end end " cart.rb has: "class Cart attr_reader :items attr_reader :total_price def initialize @items = [] @total_price = 0.0 end def add_product(product) @items << LineItem.for_product(product) @total_price += product.price end end " I...
2006 Jan 06
3
Where to place a global function
Hi all, I have a little function called format_price(price) that simply formats the argument as a dollar sign, dollar amount, dot and penny amount. Then, in a .rhtml file, I could do this: <%= format_price(item.unit_price * item.quantity) %> But where do I put the format_price() function definition? The app couldn''t find it in app/controllers/application.rb. Where do I put it so it''s available to all views? Thanks SteveT Steve Litt Author: * Universal Troubleshooting Process courseware...
2005 Dec 23
5
Can''t get data from products into @order
I went throught the "agile web developemnt with rails" and Now I''m trying to ''enhance'' the code with some extra options. When I go to admin/shipping I want to include some data from the products table in with the order info listed. I can''t seem to get this to work. in my partial form I''m trying to add this: <td
2008 Oct 08
2
Creating a matrix
Good evening. I have this following table and I would like to turn it into a matrix in which my rows would be filled with de "Sellers", my columns with my "Articles" and my data would be the mean unitary price used by each seller in each produt. Seller Art. Unit Price 1 v1 p1 9.148352 2 v2 p1 2.858073 3 v3 p1 3.775315 4 v4
2006 Aug 14
1
NoMethodError
Hello, When i test this code <h1>contenu de votre panier</h1> <table> <% for item in @items product = item.product %> <tr> <td><%= item.quantity %></td> <td><%= h(product.title)%></td> <td align="right"><%=item.unit_price %></td> <td align="right"><%=item.unit_price * item.quantity %></td> </tr> <% end %> </table> I saw this message NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #5 raised: undefined method `product&...
2006 Mar 22
1
How to retrieve attribute values of objects?????
...duct1.inspect =========================== So I am getting on console following output. ========================== [#<Product:0x3cd61c8 @attributes={"demand"=>nil, "name"=>"Part2", "quantity"=>"4", "id"=>"3", "unit_price"=>"1.000"}>] ========================== But when I am writing "print @product1.name" instead of "print @product1.inspect" in my code for displaying just name on console I m getting following error:- ========================= undefined method `name'...
2006 Feb 22
0
Need help getting value from text_field_with_autocomplete
...t;td rowspan="2" align="center"><input type="text" name="product_name[#{@ product.id}]" size="30" value="<%= @product.product_name %>"></td> <td align="center"><input type="text" name="unit_price[#{@product.id}]" size="5", value="<%= @product.unit_price %>"></td> <td align="center"><input type="text" name="sell_price[#{@product.id}]" size="5"></td> </tr> <tr> <td align="cent...
2006 Feb 27
1
Odd problem in Agile tutorial
...s/store_controller.rb:9:in `add_to_cart'' The only method that I can see called in line 13 is #find since product_id is a defined column in line_items: CREATE TABLE line_items ( id bigserial NOT NULL, product_id bigint NOT NULL, quantity numeric(10,2) DEFAULT 0 NOT NULL, unit_price money NOT NULL ) WITHOUT OIDS; with this as line_items.rb in app/models #-------------------------------------------------------------------------- 1 class LineItem < ActiveRecord::Base 2 3 belongs_to :product 4 5 def self.for_product(product) 6 item...
2006 Feb 28
2
Comment out RHTML code?
I''d like to be able to comment out a few lines of RHTML code easily. With HTML you can just surround the code in <!-- ... -->, but if you do that with the RHTML, it still gets executed, then the resulting HTML is commented out. Sometimes I''d like to be able to leave the code in but not have it evaluated..usually just for quick tests, but sometimes I want to take the
2011 Jun 15
0
Year cost optimisation
...roducts a cheaper alternative (takes a awfull lot of time), I would like to concentrate on a top 20 for example. Maybe calculate the pct contribution to the total budget, and take the top 20? Any other ideas for an approach? Here an example dataframe: dat <- data.frame(item=1:160, unit_price=round(c(runif(80,0,100), runif(80,250,1000)),2), count=round(c(runif(40, 1,10), runif(40,20,1000),runif(40, 1,10), runif(40,20,1000)),0), total=0) dat$total = dat$count*dat$unit_price Bart -- View this message in context: http://r.789695.n4.nabble.com/Year-cost-optimisati...
2006 Aug 07
0
Re:
...seen the errata or >have any ideas? I would think that if we''re getting the same results, >surely there''s someone else out there who knows what''s going on. I had similar problems, turns out in the method LineItem#for_product the last line for me was "item.unit_price = product.price", so this was returning the float rather than the "item" object itself. All you need is to add a line "item" which would return the object rather than the float - class LineItem < ActiveRecord::Base belongs_to :product def LineItem.for_product...
2006 Mar 17
1
How to update values in database in this form?
...le Qty. </th> <th> Demand Qty. </th> </tr> <% for product in @products %> <tr> <td> <%=hidden_field ''product'',''product_id''+i.to_s, :value=>product.id%> <%=product.name%> </td> <td> <%=product.unit_price%> </td> <td> <%=product.quantity%> </td> <td> <%=text_field("product", "dem_quantity"+i.to_s, "size" => 20)%> </td> </tr> <% i=i+1 %> <% end%> <tr> <%=hidden_field ''product'',...
2007 Feb 16
4
Ideas for rails
Here are a few suggestions, wondering what others thought: When you generate a model for a DB table, it would be nice if the model.rb contained the DB schema (kind of like # commented out schema) right in the model file. This would make reference WAY easier and put all of the DB stuff in one easy file. Thanks. also nice, of course, woudl be for rails to try and ''guess'' the