Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReservationsController < ApplicationController
- def index
- @reservations = Reservation.find(:all)
- end
- def new
- cabin = CabinType.find(:first,
- :conditions => ['lower(name) = ?', params[:cabin_type].downcase])
- raise "invalid cabin type: #{params[:cabin_type]}" if cabin.nil?
- @reservation = Reservation.new(:cabin_type => cabin)
- end
- def create
- @reservation = Reservation.new(params[:reservation])
- if @reservation.save
- redirect_to @reservation
- else
- render :action => "new"
- end
- end
- end
Add Comment
Please, Sign In to add comment