lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.8 vs lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.9

- old
+ new

@@ -34,14 +34,29 @@ unless options.delete :no_prefix url = ActionController::Base.relative_url_root + path else url = path end - options = options.merge default_url_options + + options = default_url_options.merge options + + # Delete 'nil' parameters + to_delete = [] + options.each{|k, v| to_delete << k if v.nil?} + to_delete.each{|k| options.delete k} + + host = options.delete :host + url << "?#{options.to_query}" unless options.empty? - url._url_format = options[:format] if options[:format] # for links with ajax support + url._url_format = options[:format] if options[:format] # hack for links with ajax support url + + if host.blank? + url + else + "http://#{host}#{url}" + end end helper_method :url_for_path # @@ -50,9 +65,10 @@ def catch_user_error begin yield rescue UserError => e flash[:error] = e.message + flash[:sticky_error] = e.message do_not_persist_params do if request.xhr? or request.format == 'js' render :inline => "", :layout => 'application' else redirect_to default_path \ No newline at end of file