Class: RealtimeValidations::ValidationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Controller
Defined in:
app/controllers/realtime_validations/validations_controller.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Controller

#before_model_validation, included

Instance Method Details

#validateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/realtime_validations/validations_controller.rb', line 9

def validate
  args = identify_args
  begin
    field = identify_field
  rescue RealtimeValidationsExceptions::InvalidData
    render :json => { :field => params[:field],
                      :errors => [] }
    return
  end
  model = retrieve_or_create_model args, params[:model]
  send_messages_to_model args, model, field
  model_valid? model
  respond_to_validation retrieve_model_errors(model, field)
end