lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.21 vs lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.22

- old
+ new

@@ -88,15 +88,15 @@ around_filter :catch_user_error # # enshure domain has www. except if there's custom subdomain # - def ensure_www - # uri = Addressable::URI.parse request.url - # if uri.host.count('.') < 2 and Rails.production? and request.domain !~ /localhost/ - # uri.host = "www." + uri.host - # redirect_to uri.to_s - # end + def ensure_no_www + uri = Addressable::URI.parse request.url + if uri.host =~ /^www\./ + uri.host = uri.host.sub(/^www\./, '') + redirect_to uri.to_s + end end class << self def prepare_model aclass, opt = {} \ No newline at end of file