diff --git a/app/views/api_taster/routes/show.html.erb b/app/views/api_taster/routes/show.html.erb index 2825259..eeab34f 100644 --- a/app/views/api_taster/routes/show.html.erb +++ b/app/views/api_taster/routes/show.html.erb @@ -16,7 +16,7 @@ <% end %> <% @params.each do |param| %> - <%= form_tag @route[:path], :method => @route[:verb], :class => 'well form-horizontal', :remote => true do %> + <%= form_tag @route[:full_path], :method => @route[:verb], :class => 'well form-horizontal', :remote => true do %> <% if param[:url_params].empty? && param[:post_params].empty? %>
diff --git a/lib/api_taster/route.rb b/lib/api_taster/route.rb index e36c0ab..e0acfbf 100644 --- a/lib/api_taster/route.rb +++ b/lib/api_taster/route.rb @@ -116,12 +116,14 @@ def discover_rack_app(app) def normalise_route(route, path_prefix = nil) route.verb.source.split('|').map do |verb| + path = path_prefix.to_s + route.path.spec.to_s.sub('(.:format)', '') { - :id => @_route_counter+=1, - :name => route.name, - :verb => verb.gsub(/[$^]/, ''), - :path => path_prefix.to_s + route.path.spec.to_s.sub('(.:format)', ''), - :reqs => route.requirements + :id => @_route_counter+=1, + :name => route.name, + :verb => verb.gsub(/[$^]/, ''), + :path => path, + :full_path => rails_url_root + path, + :reqs => route.requirements } end end @@ -143,6 +145,10 @@ def hash_diff(h1, h2) h2[k] == v end.merge!(h2.dup.delete_if { |k, v| h1.has_key?(k) }) end + + def rails_url_root + ActionController::Base.relative_url_root.to_s.chomp('/') + end end end end