开发者

Getting the id with a rails find with :select

开发者 https://www.devze.com 2023-01-19 05:47 出处:网络
I have this rails find that i need to get the id as well but if i put the id in the :select wont it effect the query and is there another way to get the id

I have this rails find that i need to get the id as well but if i put the id in the :select wont it effect the query and is there another way to get the id

@past_requests = Requ开发者_开发技巧est.find_all_by_artist(name, :conditions => ["showdate < ?", Time.now], :select => "distinct venue, showdate")


@past_requests = Request.find_all_by_artist(name, :group => "venue, showdate")

code long for view. i'm remove your condition. sorry about this. Hope it'll helpful for you. :)


To be fair in cases where distinct returns a single row out of maybe 5 duplicates who's to say which id out of those 5 should be displayed in your result? I'm afraid what you are asking for is not practical. Maybe you misunderstand what distinct is used for ? Give us more info pls.

0

精彩评论

暂无评论...
验证码 换一张
取 消