Sha256: 3e7f05eeab388b1394641f36fd8c7539532b7823b4ca59b3cad90ca0b36a0908

Contents?: true

Size: 758 Bytes

Versions: 9

Compression:

Stored size: 758 Bytes

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
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails-ext-0.2.9 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.8 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.7 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.6 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.5 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.4 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.3 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.1 lib/rails_ext/action_controller_ext.rb
rails-ext-0.2.0 lib/rails_ext/action_controller_ext.rb