I want to run next code in Rails:
boatData = Boat.find_by_sql(["SELECT bm.name as name1, bt.name as name2
FROM boat_models bm, boat_types bt, boats b
WHERE b.id = ?
AND bm.id = b.boat_model_id
AND bt.id = bm.boat_type_id", boatId]).first
puts "boatData=" + boatData.inspect
description = "Booking: " + boatData[:name1] + "(" + boatData[:name2].to_s + ")"
The only problem is the fields in the select have the same name. When I try to add "as" the results are not right.
UPDATE:
This it the output of puts "boatData=" + boatData.inspect
boatData=#<BoatModel id: nil, name: "Velero">