Hi, it's expected to get a dataset back. If you wish to get the info out, you need to use .all or .first.
environment_id = *self*[:environments].select(:id).*where*(name: 'Development').all.first environment_id = *self*[:environments].select(:id).*where*(name: 'Development').first Another possibility: environment_id = *self*[:environments].*where*(name: 'Development'). select_map(:id).first On Mon, Nov 17, 2014 at 7:46 AM, Ben Sullivan <[email protected]> wrote: > Hi > > How do I select a table column value into a variable inside a migration? > > I'm trying to do this: > > environment_id = *self*[:environments].select(:id).*where*(name: > 'Development') > > but I seem to get a dataset back instead of a value? > > I want to use the value returned to populate the foreign key field for > newly inserted rows in another table. > > Thanks > > Ben > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sequel-talk. > For more options, visit https://groups.google.com/d/optout. > -- Christian -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
