title: ActiveRecord Json Should fail no?
body: <p>I am using the <a href="https://github.com/mirego/activerecord_json_validator" rel="nofollow">ActiveRecord Json Validator Gem</a> and I have the following object thats trying to be saved to the model, which should fail, but instead isnt:</p>
  
  <pre><code>[1] pry(#&lt;Api::Internal::V1::UsersController&gt;)&gt; backup
  =&gt; #&lt;UserBackup:0x24eddeed
   id: nil,
   location_name: "test",
   user_params: {"user"=&gt;{"user_name"=&gt;"GeorgeLucas", "email"=&gt;"asdsadasdas", "auth_token"=&gt;"jesus"}, "controller"=&gt;"api/internal/v1/users", "action"=&gt;"create"}&gt;
  [2] pry(#&lt;Api::Internal::V1::UsersController&gt;)&gt; backup.save!
  =&gt; true
  </code></pre>
  
  <p>As you can see theres a unsaved <code>UserBackup</code> model object in <code>[1]</code> and in <code>[2]</code> is saves, the json in <code>[1]</code> is missing somethig that is set to required: <code>first_name</code>.</p>
  
  <p>The model looks like such:</p>
  
  <pre><code>class UserBackup &lt; ActiveRecord::Base
    PROFILE_JSON_SCHEMA = Rails.root.join('config', 'schemas', 'user.json_schema').to_s
  
    validates :location_name, :presence =&gt; true
    validates :user_params, :presence =&gt; true, json: {schema: PROFILE_JSON_SCHEMA}
  end
  </code></pre>
  
  <p>The Json Schema Looks like:</p>
  
  <pre><code>{
      "type": "object",
      "$schema": "http://json-schema.org/draft-03/schema",
      "properties": {
        "user": {
          "first_name": {
              "type": "string",
              "required": true
          },
          "last_name": {
              "type": "string",
              "required": false
          },
          "user_name": {
              "type": "string",
              "required": true
          },
          "email": {
              "type": "string",
              "required": true,
              "format": "email"
          },
          "auth_token": {
              "type": "string",
              "required": true
          }
        }
      }
  }
  </code></pre>
  
  <p>According to my schema, <code>first_name</code> must be a string and it is a required field.</p>
  
  <p>In my json being saved, its missing entirely. Which means that the model should not save the object to the database.</p>
  
  <h1>Update One:</h1>
  
  <p>Looking at the model object the <code>user_params</code> doesn't look like a json object at all, it looks like a hash of hashes. So with that in mind, here is the controller:</p>
  
  <pre><code>module Api
    module Internal
      module V1
        class UsersController &lt; BaseController
          before_action :restrict_api_access
  
          def create
            params_json = params.to_json
            backup = UserBackup.new(location_name: from_site, user_params: params_json)
            binding.pry
            if backup.save
              return render json: {}, status: 200
            else
              return render json: {}, status: 422
            end
          end
  
        end
      end
    end
  end
  </code></pre>
  
  <p><code>params_json</code> is indeed a json object:</p>
  
  <pre><code>[3] pry(#&lt;Api::Internal::V1::UsersController&gt;)&gt; params_json
  =&gt; "{\"user\":{\"user_name\":\"GeorgeLucas\",\"email\":\"asdsadasdas\",\"auth_token\":\"jesus\"},\"controller\":\"api/internal/v1/users\",\"action\":\"create\"}"
  </code></pre>
  
  <p>So I am unsure at this point, what exactly is going on.</p>