#rubyonrails - Thu 29 Mar 2007 between 00:00 and 00:23

NY Lost Funds



joevandykHow can I say this in AR? select sum((product_price - product_cost) * quantity) as profit, product_id from orders group by product_id order by product_id desc;
ben_hin the model, you could def profit; ((product_price - product_cost) * quantity); end
then maybe write a class method to return the grouped array
SkolemHow do you figure out what rails version is installed?
psticknebut the sum is all kept in the DB...
ben_hSkolem: rails --version
Skolemrails -v creates a rails skeleton directory called '-v'.
thanks!
joevandykbenh: that would be really really slow. I'd like to keep it to one query.
ben_hjoevandyk: in that case just use SQL
joevandykben_h: I'd use find?
ben_h: with options?
ben_hi don't think there's an AR way to do things like that without losing the efficiency
psticknejoevandyk, there are a bunch of options of find(), :select => "sum(....)", :oder => "foo desc", etc
joevandykpstickne: ok, so i'd use find. thanks.
psticknejoevandyk, I'd just hide it all in a nice method and forget about it ;)
joevandyk, might actually look at count_by_sql
ben_hya if half your find parameters are going to be SQL fragments anyway
psticknejoevandyk, since you're just returning a single value vs. record(s)
joevandykactually, the one I need looks a little bit like select sum((product_price - product_cost) * orders.quantity) as profit, product_id, products.name from orders, products where products.id = orders.product_id group by product_id, products.name order by product_id desc;
asdxhttp://www.linux-watch.com/news/NS5306151939.html
wtf is that?
NewMonarchWhat's the difference between TextDrive and Joyent?
ben_hi think textdrive is a subsidiary of joyent
pstickneasdx, so?
NewMonarchI think I'm just going to give Grid-Server a spin on MT.
I'm too curious not to.
asdxpstickne: i don't understand very well the point of that article, linux is developed by hackers around the globe, those that the author mention are distributions, and some propietary applications that works on linux.
re
theRemixasdx how is that news bad?
i mean, for linux users
asdxtheRemix: i don't know, i just don't get the point of it
theRemixasdx: me neither
fylgoodis there a way to take an entry in a database (a string field), read it in, and then evaluate ruby code in it? I want to have a product description that contains some personalization, so I would like to be able to mark in the description where to insert personalization info.
theRemixnow if only capistrano would work... that would be news :D
asdx:)
theRemixi can't believe i wasted a month trying to get it to work"
that should be the title of the web article
fylgoodfor example the description stored in the database would be "The Sharp DVD player is awesome. #{person.name} you will love it more than the Sony player"
after you read it in, it would eval the ruby code.

Page: 2 9 16 23 30 37 44 51 58 65 72 79 

IrcArchive

NY Lost Funds