| Class | PropertyController |
| In: |
app/controllers/property_controller.rb
|
| Parent: | ApplicationController |
************************************************************************/
************************************************************************/
# File app/controllers/property_controller.rb, line 35
35: def create
36: @property = Property.new(params[:property])
37: @property.user_id = session[:user_id]
38: if @property.save
39: flash[:notice] = 'Property was successfully created.'
40: redirect_to :action => 'list'
41: else
42: render :action => 'new'
43: end
44: end
# File app/controllers/property_controller.rb, line 60
60: def destroy
61: if Room.count(["property_id = ?", params[:id]]) > 0
62: flash[:notice] = 'Property has rooms - delete them first.'
63: redirect_to :action => 'list'
64: else
65: Property.find(params[:id]).destroy
66: redirect_to :action => 'list'
67: end
68:
69: end
# File app/controllers/property_controller.rb, line 46
46: def edit
47: @property = Property.find(params[:id])
48: end
# File app/controllers/property_controller.rb, line 17
17: def index
18: list
19: render :action => 'list'
20: end
# File app/controllers/property_controller.rb, line 22
22: def list
23: @property_pages, @properties = paginate :property, :per_page => 10, :conditions => ["user_id = ?",session[:user_id]]
24: @user
25: end
# File app/controllers/property_controller.rb, line 31
31: def new
32: @property = Property.new
33: end
# File app/controllers/property_controller.rb, line 71
71: def public_code
72: @user_id = session[:user_id]
73: @property = Property.find(:first, :conditions => ["user_id = ?", session[:user_id]])
74: end
# File app/controllers/property_controller.rb, line 27
27: def show
28: @property = Property.find(params[:id])
29: end
# File app/controllers/property_controller.rb, line 50
50: def update
51: @property = Property.find(params[:id])
52: if @property.update_attributes(params[:property])
53: flash[:notice] = 'Property was successfully updated.'
54: redirect_to :action => 'show', :id => @property
55: else
56: render :action => 'edit'
57: end
58: end