module Railjet::Util::FormHelper
Public Instance Methods
form(klass)
click to toggle source
# File lib/railjet/util/form_helper.rb, line 4 def form(klass) klass.new(clean_params).tap(&:validate!) end
Private Instance Methods
clean_params()
click to toggle source
# File lib/railjet/util/form_helper.rb, line 14 def clean_params object_params end
object_params()
click to toggle source
# File lib/railjet/util/form_helper.rb, line 10 def object_params raise NotImplementedError end
respond_with_errors(object_with_errors, status: :unprocessable_entity)
click to toggle source
# File lib/railjet/util/form_helper.rb, line 18 def respond_with_errors(object_with_errors, status: :unprocessable_entity) raise ArgumentError unless object_with_errors.respond_to?(:errors) response = object_with_errors.errors.to_hash(true) render json: response, status: status end