Rails Model.where how do I get ID? -
i have following statement:
<% location = location.where('locname' == client.locname) %> how .id of location record found?
this didn't work:
<% location = location.where('locname' == client.locname).id %> thanks help!
<% location = location.where("locname = ?", client.locname).first.id %> the reason where return activerecord::relation, can either loop through elements or grab first 1 did above.
Comments
Post a Comment