Skip to content

Instantly share code, notes, and snippets.

@benmiles
Created March 8, 2012 12:19
Show Gist options
  • Save benmiles/2000760 to your computer and use it in GitHub Desktop.
Save benmiles/2000760 to your computer and use it in GitHub Desktop.
[9] pry(main)> "10.1038/nj.hafalla.2007.json"[%r{10\.1038/.+(?=\.json)}]
=> "10.1038/nj.hafalla.2007"
@hannakalinowska
Copy link

# routes.rb
resources :articles, :id => /10\.1038(.+?)/i, :format => /xml|html|json/

# application_controller.rb
class ApplicationController < ActionController::Base
  before_filter :id

  def id
    raise params[:id]
  end
end

http://ps.dev/articles/10.1038/nj.hafalla.2007.json
# => 10.1038/nj.hafalla.2007

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