Class AddonController
In: app/controllers/addon_controller.rb
Parent: ApplicationController

************************************************************************/

  • SOLUNAS BOOKING ENGINE */
  • ====================== */
  • */
  • Copyright © 2006 by Marc Isemann */
  • sourceforge.net/projects/solunas */
  • */
  • This program is free software. You can redistribute it and/or modify */
  • it under the terms of the GNU General Public License as published by */
  • the Free Software Foundation; either version 2 of the License. */

************************************************************************/

Methods

create   destroy   edit   index   list   new   show   update  

Public Instance methods

[Source]

    # File app/controllers/addon_controller.rb, line 39
39:   def create
40:     @addon = Addon.new(params[:addon])
41:     @addon.user_id = session[:user_id]
42:     if @addon.save
43:       flash[:notice] = 'Addon was successfully created.'
44:       redirect_to :action => 'list'
45:     else
46:       render :action => 'new'
47:     end
48:   end

[Source]

    # File app/controllers/addon_controller.rb, line 66
66:   def destroy
67:     Addon.find(params[:id]).destroy
68:     redirect_to :action => 'list'
69:   end

[Source]

    # File app/controllers/addon_controller.rb, line 50
50:   def edit
51:     @addon = Addon.find(params[:id])
52:     @rooms = Room.find(:all, :conditions => ["user_id = ?", session[:user_id]])
53:   end

[Source]

    # File app/controllers/addon_controller.rb, line 18
18:   def index
19:     list
20:     render :action => 'list'
21:   end

[Source]

    # File app/controllers/addon_controller.rb, line 23
23:   def list
24:     @addon_pages, @addons = paginate :addons, :per_page => 10, :conditions => ["user_id = ?",session[:user_id]]
25:   end

[Source]

    # File app/controllers/addon_controller.rb, line 31
31:   def new
32:     @addon = Addon.new
33:     if (@rooms = Room.find(:all, :conditions => ["user_id = ?",session[:user_id]])).length == 0
34:     flash[:notice] = 'Add a room first.'
35:       redirect_to(:action => 'new', :controller => 'room')
36:     end
37:   end

[Source]

    # File app/controllers/addon_controller.rb, line 27
27:   def show
28:     @addon = Addon.find(params[:id])
29:   end

[Source]

    # File app/controllers/addon_controller.rb, line 55
55:   def update
56:     @addon = Addon.find(params[:id])
57:     @addon.user_id = session[:user_id]
58:     if @addon.update_attributes(params[:addon])
59:       flash[:notice] = 'Addon was successfully updated.'
60:       redirect_to :action => 'show', :id => @addon
61:     else
62:       render :action => 'edit'
63:     end
64:   end

[Validate]