开发者

random ids from database?

I have following question.

I DO THIS:

 @inquiry  = Survey::Inquiry.find(:all, :conditions => ["respondent_id = (?) AND is_answered = 0 AND is_denied = 0", respondent.id])

I get inquiries (relation table bet开发者_开发问答ween answer & question) ids. For example i get 2: 566, 666 . But i need only 1! how i can get ONE id from this my range (REMEMBER THAT TOTALY I HAVE 2 ids)

And what i should write in view? Now i write:

<% @inquiry.each do |ff| %>
    <%= ff.id %>
<% end %>

but i need to get 1 ID.. 666 or 566, when i will press button 'refresh' i will get 666 or 566, 566 or 666!

thank you!


Maybe you can use ":order => 'RANDOM()'" ?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜