Skip to content

Instantly share code, notes, and snippets.

@damien
Created March 21, 2012 18:32
Show Gist options
  • Save damien/2150871 to your computer and use it in GitHub Desktop.
Save damien/2150871 to your computer and use it in GitHub Desktop.
Collect records and save them as a list of URLs from within the rails console.
target = URI.parse("http://www.your-host.org")
petitions = Petition.select([:id, :slug]).limit(10)
urls = petitions.map { |p| app.url_for(:subdomain=>"www", :action=>"show", :controller=>"petitions", :host => target.host, :id => p.slug) }
File.open('urls.txt') { |io| urls.each { |u| io.puts u } }
@jaredatron
Copy link

Rails.app.routes.url_helpers.petition_url(petition) might be more correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment