I have the following mongoid model class:
class Exercise include Mongoid::Document field :name, :type => String field :description, :type => String belongs_to :group validates_presence_of :name, :description, :group end
And I have the following controller:
class ExercisesController < ApplicationController respond_to :json def create @exercise = Exercise.create(params[:exercise]) if @exercise.save respond_with @exercise else respond_with(@exercise.errors, :status => :unprocessable_entity) end end end
The model retains the penalty when it is valid, but when the following line is executed:
respond_with(@exercise.errors, :status => :unprocessable_entity)
I get the following error
undefined method `` model_name '' for ActiveModel :: Errors: Class
The error collection is full, so I think the response_with syntax is incorrect.
source share