Class: BookingsController
- Inherits:
-
HasAccountsController
- Object
- HasAccountsController
- BookingsController
- Defined in:
- app/controllers/bookings_controller.rb
Instance Method Summary collapse
- #copy ⇒ Object
- #create ⇒ Object
-
#index ⇒ Object
Actions.
- #new ⇒ Object
- #select ⇒ Object
- #select_booking ⇒ Object
- #simple_edit ⇒ Object
Instance Method Details
#copy ⇒ Object
54 55 56 57 58 59 60 |
# File 'app/controllers/bookings_controller.rb', line 54 def copy original_booking = Booking.find(params[:id]) @booking = original_booking.dup render 'edit' end |
#create ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/bookings_controller.rb', line 43 def create @booking = Booking.new(params[:booking]) create! do |success, failure| success.html do redirect_to new_booking_path end failure.html {render 'edit'} end end |
#index ⇒ Object
Actions
7 8 9 10 |
# File 'app/controllers/bookings_controller.rb', line 7 def index # @bookings = apply_scopes(Booking).accessible_by(current_ability, :list).includes(:credit_account, :debit_account).paginate(:page => params[:page], :per_page => params[:per_page]) index! end |
#new ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/bookings_controller.rb', line 12 def new @booking = Booking.new(:value_date => Date.today) # Only include base class records @booking_templates = BookingTemplate.where(:type => [nil, 'BookingTemplate']).where("NOT(code LIKE '%:%')").paginate(:page => params[:page]) new! end |
#select ⇒ Object
36 37 38 39 40 41 |
# File 'app/controllers/bookings_controller.rb', line 36 def select @booking = Booking.new(params[:booking]) increment_booking_code @booking_templates = BookingTemplate.where(:type => [nil, 'BookingTemplate']).where("NOT(code LIKE '%:%')").paginate(:page => params[:page]) @bookings = Booking.where("title LIKE ?", '%' + @booking.title + '%').order('value_date DESC').paginate(:page => params[:page]) end |
#select_booking ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/bookings_controller.rb', line 19 def select_booking @booking = Booking.find(params[:id]).dup # Clear reference @booking.reference = nil increment_booking_code # Take value date from form @booking.value_date = params[:booking][:value_date] render :action => 'simple_edit' end |
#simple_edit ⇒ Object
32 33 34 |
# File 'app/controllers/bookings_controller.rb', line 32 def simple_edit new! end |