Guest User

Untitled

a guest
Jun 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class ReservationsController < ApplicationController
  2. def index
  3. @reservations = Reservation.find(:all)
  4. end
  5.  
  6. def new
  7. cabin = CabinType.find(:first,
  8. :conditions => ['lower(name) = ?', params[:cabin_type].downcase])
  9. raise "invalid cabin type: #{params[:cabin_type]}" if cabin.nil?
  10.  
  11. @reservation = Reservation.new(:cabin_type => cabin)
  12. end
  13.  
  14. def create
  15. @reservation = Reservation.new(params[:reservation])
  16. if @reservation.save
  17. redirect_to @reservation
  18. else
  19. render :action => "new"
  20. end
  21. end
  22. end
Add Comment
Please, Sign In to add comment