Post.order('created_at DESC').limit(1).pluck(:big_id, :customer).flatten
Will return what you're looking for. flatten
gets rid of nested arrays. first
also works, but you know that your query will return no more than one record. For edge cases, you won't have to do nil checking after flatten
because calling it on an empty array returns an empty array.
Also, the select
method will return an array of active record objects that only have the big_id
and customer
attributes populated, not an array of arrays.
NOTE:. If you're looking to change the limit to anything greater than 1, flatten
will not work.