On 25 January 2016 at 14:03, Matti Ezzat <lists@ruby-forum.com> wrote:
> the below codes are not working, What I want is just random result with
> specific option
What below codes, there is nothing below in your email. Remember this
is a mailing list not a forum (though you may be accessing it via a
forum-like interface), so if you don't quote the previous message then
we have to go searching back through previous posts.
I assume that you mean this code:
offset = rand(Restaurant.where(vegan: false).count)
@restaurant = Restaurant.where(vegan: false).offset(offset).first
If so then what do you mean by 'it is not working'? Do you mean that
it is not returning a random record where vegan is false, or do you
mean that you do not want a random record with vegan false? If the
former then what *is* the code doing? If you mean the latter then
what is the difference between 'a random record with vegan false' and
what you have asked for which is 'a random result with specific
option'?
I am doing my best to help but if you do not explain your requirement
carefully then it is difficult for me. Perhaps you should give a more
detailed example, with real values, of what you want to happen.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLt6hb23BbTYoDBCrqZpnT-OA8zFm%2Bue%3DOvkmF2Bh54dKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment