I have a random webpage link below that works if you reload the page each time and don't hit the "back" button on your browser. Is there a way to get this to be a new link every click by using Ruby/Rails? Or would this be something I'd have to use JS or something for? Reason I ask is because I have no experience with any other languages. Maybe there is a way to auto_reload the webpage every 10 seconds or something similar?
Webpage Model
class Webpage < ActiveRecord::Base
validates_presence_of :link
def self.randomize_webpages
all.shuffle.first.link
end
end
WebpagesController
def index
@webpages = Webpage.all
end
View
<%= link_to 'Take Me Anywhere But Here', @random_page %>
CSV
CSV seeder for Webpage
link
http://www.buzzfeed.com
http://www.reddit.com
http://boston.com
http://phys.org
http://www.popsci.com
http://www.technologyreview.com
http://techcrunch.com
View Index.html.erb