나는 simple_form에 사용하기 위해, 가상 속성을 가진 모델을 가지고 :Inherited_resources 사용자 지정 오류
class Sms < ActiveRecord::Base
attr_accessor :delayed_send, :send_time_date, :send_time_time
I 양식을위한/SMS에/새 :
= simple_form_for([:admin, resource]) do |f|
...
.clear
.field.grid_3
= f.input :delayed_send, :as => :boolean, :label => "Отложенная отправка на:"
.clear
.field.grid_3
= f.input :send_time_date, :as => :string, :input_html => { :class => 'date_picker' }, :disabled => true, :label => "Дату:"
.clear
.field.grid_1
= f.input :send_time_time, :as => :string, :disabled => true, :label => "Время:", :input_html => { :value => (Time.now + 1.minute).strftime("%H:%M") }
.clear
.actions.grid_3
= f.submit "Отправить"
그리고 내가 싶어 안에 모든 가상 속성을 확인 내 SmsesController, 작업 만들기, 그리고 그것이 유효하지 않은 경우 - 오류를 보여줍니다. 그러나 그것은 작동하지 않습니다
class Admin::SmsesController < Admin::InheritedResources
def create
@sms.errors.add(:send_time, "Incorrect") if composed_send_time_invalid?
super
end
내가 inherited_resources를 사용하는 경우
어떻게 내가, 내 사용자 지정 오류를 추가해야합니까? 당신이 컨트롤러의 유효성을 검사하고 특정 이유가 아니라면
컨트롤러가 아닌 컨트롤러에서 유효성 검사를 수행해야하는 특별한 이유가 있습니까? – miked