Trying to get a grasp on how ruby works with data, so used to perl. Here is what im trying to do in my app/models scrap.rb
def self.START
all = MyDb.find_all_by_server_name('myserver', :limit => 1)
puts all # all i get back here is the address <MyDb:0x9c56058>
use inspect to get a better view of what you have (it's sorta like Data::Dumper):
puts all.inspect
puts all[1] # i want element 1 but i get "nil"
end
all[1] is the *second* element of the array. all[0] or all.first would be the first. Also, when you use find_all, you will get an empty array if the query doesn't find any matches.
If you just want the first match, use find_by_server_name (no "all" and no :limit). That returns either a single object (if a row is found), or nil if nothing was found.
row = MyModel.find_by_server_name 'myserver' puts row.inspect
HTH