class AutoForme::Frameworks::Rails::Request

Public Class Methods

new(request) click to toggle source
   # File lib/autoforme/frameworks/rails.rb
 7 def initialize(request)
 8   @controller = request
 9   @params = request.params
10   @session = request.session
11   @env = request.request.env
12   @method = @env['REQUEST_METHOD']
13   @model = @params['autoforme_model']
14   @action_type = @params['autoforme_action']
15   @path = @env['SCRIPT_NAME']
16   @id = @params['id']
17   @id = nil if @id && @id.empty?
18 end

Public Instance Methods

csrf_token_hash(action=nil) click to toggle source

Use Rails's form_authenticity_token for CSRF protection.

   # File lib/autoforme/frameworks/rails.rb
32 def csrf_token_hash(action=nil)
33   vc = @controller.view_context
34   {vc.request_forgery_protection_token.to_s=>vc.form_authenticity_token} if vc.protect_against_forgery?
35 end
redirect(path) click to toggle source

Implement redirects in the Rails support using throw/catch, similar to how they are natively implemented in Sinatra.

   # File lib/autoforme/frameworks/rails.rb
22 def redirect(path)
23   throw :redirect, path
24 end
xhr?() click to toggle source

Whether the request is an asynchronous request

   # File lib/autoforme/frameworks/rails.rb
27 def xhr?
28   @controller.request.xhr?
29 end