2013-04-09 09:53:23 +08:00
|
|
|
# perf fixes, review for each rails upgrade.
|
|
|
|
|
2013-04-24 12:40:55 +08:00
|
|
|
# we call this a lot
|
|
|
|
class ActiveRecord::Base
|
|
|
|
def present?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
def blank?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-09-12 13:39:02 +08:00
|
|
|
unless rails4?
|
|
|
|
class ActionView::Helpers::AssetTagHelper::AssetIncludeTag
|
|
|
|
private
|
2013-04-09 09:53:23 +08:00
|
|
|
|
2013-09-12 13:39:02 +08:00
|
|
|
# pluralization is fairly expensive, and pluralizing the word javascript 400 times is pointless
|
|
|
|
# this is fixed in Rails 4
|
2013-04-09 09:53:23 +08:00
|
|
|
|
2013-09-12 13:39:02 +08:00
|
|
|
def path_to_asset(source, options = {})
|
|
|
|
asset_paths.compute_public_path(source, pluralize_asset_name(asset_name), options.merge(:ext => extension))
|
|
|
|
end
|
2013-04-09 09:53:23 +08:00
|
|
|
|
|
|
|
|
2013-09-12 13:39:02 +08:00
|
|
|
def path_to_asset_source(source)
|
|
|
|
asset_paths.compute_source_path(source, pluralize_asset_name(asset_name), extension)
|
|
|
|
end
|
2013-04-09 09:53:23 +08:00
|
|
|
|
|
|
|
|
2013-09-12 13:39:02 +08:00
|
|
|
def pluralize_asset_name(asset_name)
|
|
|
|
@@pluralization_cache ||= {}
|
|
|
|
plural = @@pluralization_cache[asset_name] ||= asset_name.to_s.pluralize
|
|
|
|
end
|
2013-04-09 09:53:23 +08:00
|
|
|
|
2013-09-12 13:39:02 +08:00
|
|
|
end
|
2013-04-09 09:53:23 +08:00
|
|
|
end
|
|
|
|
|