Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #MODEL
- #models/reservations/booking.rb
- module Reservations
- # Klasa reprezentująca rezerwacje.
- class Booking < ActiveRecord::Base
- set_table_name 'reservations_bookings'
- include Reservations::Validations
- attr_accessible :hotel_id, :start_date, :end_date, :currency,
- :first_name, :last_name, :email, :phone_number, :special_requests,
- :cc_type, :cc_number, :cc_first_name, :cc_last_name, :cc_expiration_date, :cc_cvc,
- :existing_bookings_rooms_attrs, :total_rake, :payed_rake,
- :addr_street_name, :addr_house_number, :addr_flat_number,
- :addr_postal_code, :addr_city, :addr_country, :full_guest_name, :room_id
- # Properties
- acts_as_paranoid
- has_friendly_id :token, :approximate_ascii => true
- end
- end
- #MODUL
- #models/reservations/booking_modules/validations.rb
- require 'active_support/concern'
- module Reservations
- module Validations
- extend ActiveSupport::Concern
- included do
- validates :token, :uniqueness => true, :presence => true
- validates :hotel_id, :currency, :start_date, :end_date, :presence => true
- validate :validate_rooms
- validates_date :start_date, :on_or_after => Date.today
- validates_date :end_date, :after => :start_date
- validates :first_name, :last_name, :presence => true, :unless => :fresh?
- validates :email, :email => true, :presence => true, :confirmation => true, :unless => :fresh?
- validates :total_rake, :payed_rake, :guarantee_rake, :cancel_rake, :presence => true
- validates_associated :credit_card, :unless => :has_credit_card?
- def validate_rooms
- if self.has_rooms?
- return true
- else
- self.errors.add(:rooms, I18n.t('booking.error.no_room_chosen'))
- return false
- end
- end
- end
- end
- end
- #ERROR
- uninitialized constant Reservations::Validations (NameError)
Add Comment
Please, Sign In to add comment