lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.10 vs lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.11

- old
+ new

@@ -5,10 +5,18 @@ # url_for, used to generate url_for for string path with options and with default_url_options # ActionController::Base.class_eval do protected # + # link_to + # + def link_to text, uri + %{<a href="#{uri}">#{text}</a>} + end + + + # # Bunch of small actions # def render_action action_or_template args = action_or_template.to_s.split('/') args.size.should! :be_in, 1..2 @@ -32,29 +40,30 @@ # def url_for_path path, options = {} unless options.delete :no_prefix url = ActionController::Base.relative_url_root + path else - url = path + url = path.dup end 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) || options.delete('host') + port = options.delete(:port) || options.delete('port') url << "?#{options.to_query}" unless options.empty? url._url_format = options[:format] if options[:format] # hack for links with ajax support url if host.blank? url else - "http://#{host}#{url}" + %{http://#{host}#{":#{port}" unless port.blank?}#{url}} end end helper_method :url_for_path \ No newline at end of file