| Class | PriceController |
| In: |
app/controllers/price_controller.rb
|
| Parent: | ApplicationController |
************************************************************************/
************************************************************************/
# File app/controllers/price_controller.rb, line 43
43: def create
44: @price = Price.new(params[:price])
45: @price.user_id = session[:user_id]
46: @price.price = Price.get_default_price(params[:default_price])
47: if @price.save
48: flash[:notice] = 'Price was successfully created.'
49: redirect_to(:action => 'edit', :id => @price.id)
50: else
51: render :action => 'new'
52: end
53: end
# File app/controllers/price_controller.rb, line 96
96: def destroy
97: Price.find(params[:id]).destroy
98: redirect_to :action => 'list'
99: end
# File app/controllers/price_controller.rb, line 55
55: def edit
56: @price = Price.find(params[:id])
57: @prl = @price.price
58: @rooms = Room.find(:all, :conditions => ["user_id = ?",session[:user_id]])
59:
60: end
# File app/controllers/price_controller.rb, line 18
18: def index
19: list
20: render :action => 'list'
21: end
# File app/controllers/price_controller.rb, line 23
23: def list
24: @price_pages, @prices = paginate :price, :per_page => 10, :conditions => ["user_id = ?",session[:user_id]]
25: end
# File app/controllers/price_controller.rb, line 33
33: def new
34: @price = Price.new
35: if (@rooms = Room.find(:all, :conditions => ["user_id = ?",session[:user_id]])).length == 0
36: flash[:notice] = 'Add a room first.'
37: redirect_to(:action => 'new', :controller => 'room')
38: end
39: end
# File app/controllers/price_controller.rb, line 75
75: def new_price
76: @price = Price.find(params[:id])
77:
78: if (params[:new_price].count ";") >= 1
79: arr = Array.new
80: params[:new_price].split(";").each do |x|
81: arr << x.split(",")
82: end
83: else
84: arr = params[:new_price]
85: end
86:
87: @price.price = Price.new_price(@price, params[:start_day], params[:start_month], params[:stop_day], params[:stop_month], arr)
88: if @price.update
89: flash[:notice] = 'Price schema was successfully updated.'
90: redirect_to(:action => 'edit', :id => @price.id)
91: else
92: render :action => 'edit'
93: end
94: end
# File app/controllers/price_controller.rb, line 27
27: def show
28: @price = Price.find(params[:id])
29: @prl = @price.price
30: @rooms = Room.find(:all, :conditions => ["user_id = ?",session[:user_id]])
31: end
# File app/controllers/price_controller.rb, line 62
62: def update
63: @price = Price.find(params[:id])
64: @price.room_id=params[:price][:room_id]
65: @price.adults=params[:price][:adults]
66: @price.children=params[:price][:children]
67: if @price.update
68: flash[:notice] = 'Price was successfully updated.'
69: redirect_to :action => 'list'
70: else
71: render :action => 'edit'
72: end
73: end