Skip to content

Instantly share code, notes, and snippets.

@vsalbaba
Created May 14, 2010 17:37
Show Gist options
  • Save vsalbaba/401410 to your computer and use it in GitHub Desktop.
Save vsalbaba/401410 to your computer and use it in GitHub Desktop.
ActionController::Routing::Routes.draw do |map|
map.with_options :path_prefix => '/:account_id' do |map|
map.resources :collections
end
end
module ActionView
module Helpers
module UrlHelper
alias :real_url_for :url_for
def url_for(options={})
account_options = {:account_id => params[:account_id]}
options.merge!(account_options) if options.is_a?(Hash)
real_url_for(options)
end
end
end
end
<%= link_to h(collection.name), collection %>
#collection_url failed to generate from {:action=>"show", :account_id=>"test", :controller=>"collections"}, expected: {:action=>"show", :controller=>"collections"}, diff: {:account_id=>"test"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment