0
Rails 4.2에서 restrict_with_error 유효성 검사를 사용하려고합니다.어디에서 오류가 표시됩니까? restrict_with_error validation
이 응용 프로그램에는 여러 아파트가 있습니다. 아파트와 관련된 경우 삭제되는 것을 방지하고 싶습니다. 여기
class Area < ActiveRecord::Base
has_many :apartments, :dependent => :restrict_with_error
validates :name, presence: true
end
사용자가 영역을 삭제할 수이다 : 여기
이 지역 모델이다 나는 아파트를 연결 한 영역을 삭제하려고하면
<% @areas.each do |a| %>
<tr>
<td><%= a.id %></td>
<td><%= a.name %></td>
<td><%= a.notes %></td>
<td><%= link_to 'Destroy', a, method: :delete, data: { confirm: 'Are you sure you want to delete this area?' } %></td>
</tr>
<% end %>
</tbody>
</table>
, 그것은이다 한정된. 그러나 오류는 표시되지 않습니다.
이것은 매우 간단한 질문 일 수 있지만 삭제가 제한되면 어디에서 오류가 표시됩니까?
미리 감사드립니다.
당신은 그것으로 볼 수 : http://stackoverflow.com/questions/29090902/rails-4-2-dependent-restrict-with-error-access이 같은 지역 컨트롤러에서 수행 할 수 있습니다 오류 –