group :assets do gem 'sass-rails', '~> 3.1.5' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' gem 'compass', '>= 0.12.alpha' end
config.assets.precompile << /(^[^_]|\/[^_])[^\/]*$/
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
group :assets do gem 'sass-rails', '~> 3.1.5' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' gem 'compass', '>= 0.12.alpha' end
config.assets.precompile << /(^[^_]|\/[^_])[^\/]*$/
# Adding additional options for ajax function # You can use thisElement to manipulate element that using the function (link/button/form) def custom_remote_function_options options options[:before] ||= "" options[:loading] ||= "" options[:complete] ||= "" options[:success] ||= "" options[:before] += "; var thisElement=this" options[:failure] ||= "; eval(request.responseText)" unless options[:loading_text].blank? options[:loading] += "; thisElement.notif = #{notification_loading(options[:loading_text])}" options[:complete] += "; #{notification_remove "thisElement.notif"}" end options end # Override rails remote_function using additional options def custom_remote_function options remote_function(custom_remote_function_options(options)).html_safe end # Override rails link_to_remote function using additional options # Disabling the link when ajax loading in progress to avoid double request def custom_link_to_remote name, options={}, html_options=nil options = custom_remote_function_options options options[:loading] += "; $(thisElement).setLink(false)" options[:complete] += "; $(thisElement).setLink(true)" link_to_remote name, options, html_options end # Override rails button_to_remote function using additional options # Disabling the button when ajax loading in progress to avoid double request def custom_button_to_remote name, options={}, html_options=nil options = custom_remote_function_options options options[:loading] += "; $(thisElement).setInput(false)" options[:complete] += "; $(thisElement).setInput(true)" button_to_remote name, options, html_options end # Adding additional options for ajax form # Add :unchange_default => true to prevent successful request changing default form fields value # Add :disable_link => true to disable all link inside form when loading in progress def custom_remote_form_options options options = custom_remote_function_options options options[:loading] += "; $(':input', thisElement).setInput(false);" options[:complete] += "; $(':input', thisElement).setInput(true);" unless options[:unchange_default] options[:success] += "; $(':input', thisElement).setDefault();" end if options[:disable_link] options[:loading] += "; $('a', thisElement).setLink(false);" options[:complete] += "; $('a', thisElement).setLink(true);" end options end # Override rails remote_form_for using additional options def custom_remote_form_for record_or_name_or_array, *args, &proc args.push custom_remote_form_options(args.extract_options!) remote_form_for record_or_name_or_array, *args, &proc end alias_method :custom_form_remote_for, :custom_remote_form_for # Override rails form_remote_tag using additional options def custom_form_remote_tag options={}, &block form_remote_tag custom_remote_form_options(options), &block end alias_method :custom_remote_form_tag, :custom_form_remote_tag def custom_button_to_remote name, value, options = {} button_to_remote name, value, custom_remote_form_options(options) end # Override rails submit_to_remote using additional options def custom_submit_to_remote(name, value, options = {}) submit_to_remote(name, value, custom_remote_form_options(options)) end def notification_info text, no_escape=false text.gsub!(/\n/, ' ') text = escape_javascript(text) unless no_escape "notificationInfo('#{text}')" end def notification_loading text, no_escape=false text.gsub!(/\n/, ' ') text = escape_javascript(text) unless no_escape "notificationLoading('#{text}')" end def notification_error text, no_escape=false text.gsub!(/\n/, ' ') text = escape_javascript(text) unless no_escape "notificationError('#{text}')" end def notification_remove notification "notificationRemove(#{notification})" end
function notificationInfo(text){
return $.gritter.add({text: text.replace(/\n/g, '
')});
}
function notificationError(text){
return $.gritter.add({text: '' + text.replace(/\n/g, '
') + '',time: 6000});
}
function notificationLoading(text){
return $.gritter.add({text: text.replace(/\n/g, '
'), image: '/images/gritter-loading.gif', sticky:true})
}
function notificationRemove(notification){
$.gritter.remove(notification);
}
# system_settings/lib/system_setting.rb
class SystemSetting < ActiveRecord::Base
@@data = {}
validates_length_of :name, :in => 1..255
validates_uniqueness_of :name
serialize :value
def self.[](name)
name = name.to_s unless name.is_a? String
return @@data[name] unless @@data[name].nil?
p = SystemSetting.find_by_name(name)
@@data[name] = p ? p.value.freeze : nil
end
def self.[]=(name, value)
name = name.to_s unless name.is_a? String
p = SystemSetting.find_or_initialize_by_name(name)
@@data[name] = p.value = value
p.save!
p.value.freeze
end
end
include ExceptionLoggable rescue_from Exception, :with => :exception_handler private def exception_handler exception log_exception exception render "/500.html" end