similar to: Polymorphic Data Modelling Question

Displaying 20 results from an estimated 300 matches similar to: "Polymorphic Data Modelling Question"

2006 Jan 03
3
What''s the best way to do complex inheritance?
I have a Merchant class that has many Products. Product is an abstract class which has many subclasses (ProductA, ProductB, etc). All Products have common data, like ''name'', ''status'', ''created_on'', etc... but they also have some completely different properties. It seems like Active Record only supports Single Table Inheritance. This
2008 Sep 21
2
r format questions
Hi, 1) I have noticed that when I use the aggregate function it outputs numbers in the results. for example: aggregate by product group.1 Aggregate 1 ProductA 1000400.00 2 ProductB 23232323.00 3 Missing 232323.00 is there a way to suppress the numbers infront of aggregate outputs. I checked and they don't look like columns when I do a summary so I can't -1
2006 Jul 17
1
Updating multiple children from one page
Hello, I have a model called invoice and one called lineitem. An invoice has_many lineitems, and an lineitem belongs to an invoice. I have a model method that calculates the price of a lineitem, and one that calculates all lineitems in an invoice. I want to have an edit page that lists all the invoices lineitems and their calculated prices, with a text field for a person to change the
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 Aug 08
1
Legacy system belongs_to problem
Hi all, I am trying to patch a small rails app into a large system we have at our company. The legacy has a large database that naturally does not match the Rails conventions, but this has not been a serious problem thanks to rails flexibility. The problem I just ran into is that my "LineItems" table links back to the "Products" table using a modified foreign key. For
2003 Jan 08
2
Problem with fontsize of pie-chart in postscript file
Hi all, I've a problem with the size of the labels of my pie-charts when I try to write them to a postscript file. I need to increase the default size, so I change cex (see below). On screen this works fine, but cex doesn't seem to affect the postscript-file. Any suggestions? Thanks a lot, Daniel Copy/Past-example (will try to write to c:/temp!): labels <- c("I",
2008 Jan 19
1
Decimals are being converted to Bigdecimals!!!!!
Hi all, I''m working on a financial app, and have set up some columns in my tables as decimals with precision => 8 and scale => 2. My migration looks like: change_column :lineitems, :price, :decimal, :precision => 8, :scale => 2 change_column :payments, :amount, :decimal, :precision => 8, :scale => 2 I''ve run the migration and restarted the server. I
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 Aug 02
7
Same error ... again.
I reached page 82 of the Book "Agile Development with Rails" First Edition. After I compiled the code I got the following error message. [CODE] NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #11 raised: undefined method `product'' for 1099.0:Float 8: <table> 9: <% 10: for item in @items 11: product = item.product 12:
2007 Aug 07
0
has_and_belongs_to_many polymorphic question
I''ve got a situation where I''m trying to model the following relationship: a ''page'' has multiple lineitems a ''lineitem'' can be either a ''page'' or a ''entity'' The ''lineitem'' looks like it should be polymorphic but the ''page'' and ''lineitem''
2009 Apr 01
3
Nil being coerced to float
I was doing this: @line_items = LineItems.find_all_by_invoice_id(params[:id]) @payments = Payments.find_all_by_invoice_id(params[:id]) @total = @line_items.sum{ |item| item.cost } @payment_total = @payments.sum{ |payment| payment.value } @balance = @total - @payment_total But when no payments had been made it was coming up with an error when trying to sum nil, so I did
2009 May 27
4
Sale, pop and product
Hi, I couldn''t find a better word for pop, but let''s go: There are 3 models: sale, pop and product sale: -total:integer pop: -quantity:integer -discount:float product: -name:string -price:float A sale can have many different products, each one has a quantity and discount associated. So each sale has_many :products through => pops And each product has_many :sales
2008 Sep 02
5
Appending a record to a table
Hi I''m not too sure how best to explain this but here goes! I am trying to write an appointment system. I have, through example, just about got the dynamics correct. Even tried to play with some table joins (and excuse me if I''ve used the incorrect terminlogy). But no matter what I try I can''t seem to get the following code to work. I have a cart filled with Treatment
2008 Oct 29
0
RJS problem after upgrading to Rails 2.0.2
I just updated an old app from 1.2.6 to 2.0.2 and I''m having an rjs problem. I have one page that has 2 submit to remote buttons, one to do a price override and the other to remove the lineitem. Everything is working perfectly before the update but now the price override doesn''t update the page. I''ve verified that the price_override method still gets called because
2013 May 14
5
Why joins queries make result readonly?
Are there any rationalies to make queries obtained by joining scope to be readonly? I read some old posts (pre-rails3) that joins adds additional columns to record so that ActiveRecord doesn''t know how to update that fields, but actually I don''t see that fields. For example I write model class Order < ActiveRecord::Base has_and_belongs_to_many :executors, class_name:
2005 Mar 06
8
Tutorial about XMLHttpRequest+Rails
Hi All I just finished writing up a tutorial relating my experience developing a system to edit line-items ''in-line'' in my Rails application using XMLHttpRequest. I thought this might be of interest to some readers of this list... Check it out at http://hieraki.goodlad.ca/read/book/1 Thanks! Dave -- Dave Goodlad dgoodlad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
2006 Jul 21
1
How to dynamically add more rows and submit data
Let''s assume that I am trying to build an application where the user can enter invoice. In the app the user can add lines items. Each line item has decription, date, rate and hours. When the invoice screen comes up the first time I have one blank row for the line items. <tr> <th>Description</th> <th>Date</th>
2006 Aug 16
4
New Model Object from Existing Model Object
Hey Guys, need a hand again.... Lets say I have an Order... and an Order has Order Lines and Order_Lines have Items... I want to create a New Order, which would have New Order Lines with the same Items... Is there a fast / easy way to do this, w/o having to create a new order, loop through all the order lines, and create them associating them with the Items? Any help would be great, thanks --
2006 Apr 20
5
strange mysql problem
i have this model: class LineItem < ActiveRecord::Base belongs_to :quote end in the console: >>l = LineItem.create ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' , , , )'' at line 1: INSERT INTO line_items (`qty`, `quote_id`,
2007 Aug 30
3
Rails - depot application
I''m doing the depot example in the Agle Web development book. I''m getting this error: "undefined method `product'' for #<BigDecimal:331ce70,''0.21E1'',8(8)> " "Extracted source (around line #9): 8: for item in @items 9: product = item.product 10: -%> 11: <tr> 12: <td><%= item.product%></td>"