Hello,

I am quite new to ruby. I have coded in Java earlier and the code to
fire a query in ruby is a lot different and I am struggling.

I have this model

 create_table "used_cars", :force => true do |t|
    t.string   "make"
    t.string   "model"
    t.string   "trim"
    t.decimal  "engine_size_cc"
    t.string   "bodytype"
    t.decimal  "doors"
    t.string   "fuel_type"
    t.string   "car_id"
    t.string   "colour"
    t.decimal  "price"
    t.string   "dealer"
    t.string   "town"
    t.string   "cap_car_id"
    t.string   "registration_no"
    t.date     "reg_year"
    t.string   "inc_options"
    t.string   "url"
    t.datetime "created_at"
    t.datetime "updated_at"
 end

I need to generate an ad for the cheapest car..I know what query to
fire, but dont know what ruby syntax to use..I want to order it by
price...and then use different fields to print the ad.

I tried few things like
car_price = UsedCar.find_by_sql"SELECT price FROM used_cars"
or
car_price = UsedCar.find_by_price(true,true)

Also it will be really great if anybody can direct me to right study
material. I am reading agile web dev with rails and ruby cookbook. But
need to work hard on DB syntax.

Can  anybody please help!

Thanks in advance :)
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to