On Nov 2, 7:34 am, bsdev <[email protected]> wrote: > Hello! > > I'm using sequel with a PostgreSQL database. > I am a newbie and I have the following problem: I want to get a row of > the database and set the values to my object. > > I wrote in Ruby: > user = DB[:USER].filter(:EMAIL => @email).all > > The query is right (I can see it because of the log file), but how > could I get the values of the results so I can set my user object? > For example > @name = valueOfTheResultOfTheColumnName > > Thanks a lot in advance, Regards.
In Sequel, Dataset#all is going to return an array of hashes. You appear to just want the first user (since you used user instead of users), so you should do: user = DB[:USER].first(:EMAIL => @email) That will return a single hash with all columns in the USER table. To get the value of the EMAIL column: @name = user[:EMAIL] Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-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/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
