class LocationsController

Public Instance Methods

create() click to toggle source

POST /locations POST /locations.json

# File app/controllers/locations_controller.rb, line 42
def create
  @location = Location.new(params[:location])

  respond_to do |format|
    if @location.save
      format.html { redirect_to @location, :notice => 'Location was successfully created.' }
      format.json { render :json => @location, :status => :created, :location => @location }
    else
      format.html { render :action => "new" }
      format.json { render :json => @location.errors, :status => :unprocessable_entity }
    end
  end
end
destroy() click to toggle source

DELETE /locations/1 DELETE /locations/1.json

# File app/controllers/locations_controller.rb, line 74
def destroy
  @location = Location.find(params[:id])
  @location.destroy

  respond_to do |format|
    format.html { redirect_to locations_url }
    format.json { head :ok }
  end
end
edit() click to toggle source

GET /locations/1/edit

# File app/controllers/locations_controller.rb, line 36
def edit
  @location = Location.find(params[:id])
end
index() click to toggle source

GET /locations GET /locations.json

# File app/controllers/locations_controller.rb, line 4
def index
  @locations = Location.all.sort!{ |o1, o2| o1.room.name <=> o2.room.name }

  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @locations }
  end
end
new() click to toggle source

GET /locations/new GET /locations/new.json

# File app/controllers/locations_controller.rb, line 26
def new
  @location = Location.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @location }
  end
end
show() click to toggle source

GET /locations/1 GET /locations/1.json

# File app/controllers/locations_controller.rb, line 15
def show
  @location = Location.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @location }
  end
end
update() click to toggle source

PUT /locations/1 PUT /locations/1.json

# File app/controllers/locations_controller.rb, line 58
def update
  @location = Location.find(params[:id])

  respond_to do |format|
    if @location.update_attributes(params[:location])
      format.html { redirect_to @location, :notice => 'Location was successfully updated.' }
      format.json { head :ok }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @location.errors, :status => :unprocessable_entity }
    end
  end
end