Sha256: 5d74e8be009241cc3adc4870806cec10891bfeba0ec8b81fac4eb1d4844271a5
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
# # url_for, used to generate url_for for string path with options and with default_url_options # ActionController::Base.class_eval do protected def url_for_path path, options = {} unless options.delete :no_prefix url = ActionController::Base.relative_url_root + path else url = path end options = options.merge default_url_options url << "?#{options.to_query}" unless options.empty? url._url_format = options[:format] if options[:format] # for links with ajax support url end def catch_user_error begin yield rescue UserError => e flash[:error] = e.message do_not_persist_params do redirect_to default_path end end end around_filter :catch_user_error class << self def prepare_model aclass, opt = {} id = opt.delete(:id) || :id variable = opt.delete(:variable) || aclass.name.underscore method = "prepare_#{variable}" define_method method do model = aclass.find!(params[id]) instance_variable_set "@#{variable}", model end before_filter method, opt end end end
Version data entries
4 entries across 4 versions & 1 rubygems