On Sunday, November 16, 2014 10:46:38 PM UTC-8, Ben Sullivan 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?
>
For returning a single value, use Dataset#get:

  environment_id = self[:environments].where(name: 'Development').get(:id)

Thanks,
Jeremy

-- 
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.

Reply via email to