lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.17 vs lib/rails_ext/action_controller/micelaneous.rb in rails-ext-0.3.18
- old
+ new
@@ -9,13 +9,12 @@
#
# link_to
#
def link_to text, uri
%{<a href="#{uri}">#{text}</a>}
- end
+ end
-
#
# Bunch of small actions
#
def render_action action_or_template
args = action_or_template.to_s.split('/')
@@ -85,11 +84,23 @@
end
end
end
end
around_filter :catch_user_error
+
+ #
+ # enshure domain has www. except if there's custom subdomain
+ #
+ def ensure_www
+ if request.domain.count('.') < 2 and Rails.production? and request.domain !~ /localhost/
+ uri = Addressable::URI.parse request.url
+ uri.host = "www." + uri.host
+ redirect_to uri.to_s
+ end
+ end
class << self
+
def prepare_model aclass, opt = {}
id = opt.delete(:id) || :id
variable = opt.delete(:variable) || aclass.model_name.underscore
finder = opt.delete(:finder) || :find!
\ No newline at end of file