| Class | RoomController |
| In: |
app/controllers/room_controller.rb
|
| Parent: | ApplicationController |
************************************************************************/
************************************************************************/
# File app/controllers/room_controller.rb, line 38
38: def create
39: @room = Room.new(params[:room])
40: @room.user_id = session[:user_id];
41: @room.days_of_week = params[:days_of_week]
42: @room.minimum_stay = Room.get_default_minimum_stay(params[:default_minimum_stay])
43: if @room.save
44: flash[:notice] = 'room was successfully created.'
45: redirect_to :action => 'list'
46: else
47: render :action => 'new'
48: end
49: end
# File app/controllers/room_controller.rb, line 93
93: def destroy
94: Contract.delete_all(["room_id = ?", params[:id]])
95: Addon.delete_all(["room_id = ?", params[:id]])
96: Price.delete_all(["room_id = ?", params[:id]])
97: Room.find(params[:id]).destroy
98: redirect_to :action => 'list'
99:
100: end
# File app/controllers/room_controller.rb, line 51
51: def edit
52: @room = Room.find(params[:id])
53: @properties = Property.find(:all, :conditions => ["user_id = ?",session[:user_id]])
54: @documents = Document.find(:all, :conditions => ["user_id = ?", session[:user_id]])
55: @days_of_week = @room.days_of_week
56: #@prl = @room.minimum_stay
57: end
# File app/controllers/room_controller.rb, line 59
59: def edit_minimum_stay
60: @room = Room.find(params[:id])
61: @prl = @room.minimum_stay
62: end
# File app/controllers/room_controller.rb, line 16
16: def index
17: list
18: render :action => 'list'
19: end
# File app/controllers/room_controller.rb, line 21
21: def list
22: @room_pages, @rooms = paginate :room, :per_page => 10, :conditions => ["user_id = ?",session[:user_id]]
23: end
# File app/controllers/room_controller.rb, line 29
29: def new
30: @room = Room.new
31: if (@properties = Property.find(:all, :conditions => ["user_id = ?",session[:user_id]])).length == 0
32: flash[:notice] = 'Add a property first.'
33: redirect_to(:action => 'new', :controller => 'property')
34: end
35:
36: end
# File app/controllers/room_controller.rb, line 81
81: def new_minimum_stay
82: @room = Room.find(params[:id])
83: @room.minimum_stay = Room.new_minimum_stay(@room, params[:start_day], params[:start_month], params[:stop_day], params[:stop_month], params[:new_minimum_stay])
84:
85: if @room.update
86: flash[:notice] = 'Room minimum stay schema was successfully updated.'
87: redirect_to(:action => 'edit_minimum_stay', :id => @room.id)
88: else
89: render :action => 'edit_minimum_stay'
90: end
91: end
# File app/controllers/room_controller.rb, line 25
25: def show
26: @room = Room.find(params[:id])
27: end
# File app/controllers/room_controller.rb, line 64
64: def update
65: @room = Room.find(params[:id])
66: @room.days_of_week = params[:days_of_week]
67: if @params[:document_ids]
68: @room.documents = Document.find(@params[:document_ids])
69: else
70: @room.documents = []
71: end
72: if @room.update_attributes(params[:room])
73: flash[:notice] = 'Room was successfully updated'.t
74: redirect_to :action => 'edit', :id => @room
75:
76: else
77: render :action => 'edit'
78: end
79: end