每当我发送一个包含不允许的字符串的POST请求时,我的应用程序就会破坏500内部错误,错误为's' is not a valid status
我的模特
enum status: ['In progress', 'Open', 'Closed']
enum casetype: %w(Info NFI RFC RFA)
validates :status, inclusion: {
in: Subject.statuses.keys,
message: 'The only statusses allowed are: "Open", "In progress" and "Closed".' }
validates :casetype, inclusion: {
in: Subject.casetypes.keys,
message: 'The only types allowed are: "RFC", "RFA", "NFI" and "Info".' }
我的控制器
def create
@subject = Subject.new(subject_params)
if @subject.save
respond_with(@subject, status: :created)
else
respond_with(@subject, status: 403)
end
end
每当我发送一个不包含我的状态和casetype参数的POST请求时,就会引发错误消息。
每当有人发送带有无效字符串的POST请求时,是否可以引发错误消息?