Skip to content

Instantly share code, notes, and snippets.

validate :something
def something
errors.add(:person_in_charges, "mensagem_de_erro") if person_in_changes.empty?
end
class DemandsController < CrudUpdatedController
def new
object = build_resource
object.academic_year = current_academic_year
super
end
private
class SchoolStatusManager
def initialize(school)
@school = school
end
def set_status!
@school.update_attribute :status, school_status
end
describe 'POST create' do
context 'setting status' do
let :entidade do
Entidade.make!(:entidade)
end
it 'should set the status' do
post :create, :entidade => entidade.attributes
entidade.stub(:status).and_return 'calculated'
#has_many :demands
has_many :demand_stages
#has_many :enrollment_renewals
#has_many :classroom_placings
#has_many :pre_enrollments
#has_many :employee_positions
#has_many :project_classrooms
#has_many :course_evaluation_criteria
has_many :evaluation_periods
has_many :evaluation_criterion_disciplines
module ActiveRecord
module PreventChangeCloseAcademicYearDependents
def self.included(base)
base.before_destroy :validate
base.validate :validate, :on => :update
end
def validate
if (respond_to? :academic_year) && (academic_year_is_closed?)
errors.add(:base, :academic_year_is_closed)
<div class="yui3-g">
<div class="yui3-u-1-3">
<%= f.input :academic_year %>
</div>
<div class="yui3-u-2-3">
<%= f.input :school %>
</div>
</div>
def change
MultipleClassroom.all.each do |multiple_classroom|
multiple_classroom.academic_classrooms << multiple_classroom.first_academic_classroom if multiple_classroom.first_academic_classroom
multiple_classroom.academic_classrooms << multiple_classroom.second_academic_classroom if multiple_classroom.second_academic_classroom
end
end
$('#academic_classroom_course_id').bind('change', function(){
academic_classroom_id = this.value();
var url = entity_modal_path(:campo_id => academic_year_id )
$('#academic_record_mec_stage').data('modal-url', url);
});
class Alguma
def self.something
new(parametro).metodo2
end
private | protected | public
def metodo2
end