Created
January 8, 2011 16:24
-
-
Save Tyralion/770957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: UTF-8 | |
| class Booking < ActiveRecord::Base | |
| class << self | |
| abstract_class = true | |
| def columns() | |
| @columns ||= [] | |
| end # columns() | |
| def column(name, sql_type = nil, default = nil, null = true) | |
| columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) | |
| end # column(name, sql_type = nil, default = nil, null = true) | |
| def medical_specialist_select | |
| BookingExtension. | |
| specialist. | |
| all. | |
| collect {|p| [ p.name ] } | |
| end # medical_specialist | |
| def admission_form_select | |
| BookingExtension. | |
| kind_of_reception. | |
| all. | |
| collect {|p| [ p.name ] } | |
| end # admission_form_select | |
| def time_visiting_select | |
| BookingExtension. | |
| time_of_receipt. | |
| all. | |
| collect {|p| [ p.name ] } | |
| end # time_visiting_select | |
| end # class << self | |
| column :medical_specialist, :string # Специалист | |
| column :admission_form, :string # Вид приема | |
| column :time_visiting, :string # Время посещения | |
| column :data_visiting, :string # Дата посещения | |
| column :fio_doctor, :string # ФИО врача | |
| column :fio_pacient, :string # ФИО пациента | |
| column :email_pacient, :string # E-mail пациента | |
| column :phone_pacient, :string # Телефон пациента | |
| validates_presence_of :medical_specialist, :admission_form, | |
| :time_visiting, :data_visiting, :fio_doctor, | |
| :fio_pacient, :email_pacient, :phone_pacient, | |
| :message => " — Поле не может быть пустым." | |
| validates_format_of :email_pacient, | |
| :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, | |
| :message => " — Указанный e-mail адрес некорректен!", | |
| :allow_blank => true, | |
| :allow_nil => true | |
| validates_length_of :medical_specialist, :admission_form, | |
| :time_visiting, :data_visiting, :fio_doctor, | |
| :fio_pacient, :email_pacient, :phone_pacient, | |
| :maximum => 255, | |
| :message => " — Поле не более %{count} символов.", | |
| :allow_blank => true, | |
| :allow_nil => true | |
| def create_or_update | |
| if (result = errors.empty?) | |
| BookingMailer.deliver_postman(self) | |
| @new_record = false | |
| end | |
| result | |
| end # create_or_update | |
| private :create_or_update | |
| end # Booking < ActiveRecord::Base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment