ruby on rails - How would I make a link that takes you to a random article on the site? -


it wikipedia's "random article" button. takes random webpage on site.

<%= button_to "random article", article_path(random_article) %>  #app/helpers/application_helper.rb class applicationhelper    def random_article       article.order("rand()").first.pluck(:id)    end end 

with article: random record in activerecord


Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -