class LocationsController < ApplicationController uses_tiny_mce :only => [:settings] def settings @location = Location.find(params[:id]) if request.post? @location.attributes = params[:location] redirect_to location_path(@location) end end # GET /locations # GET /locations.xml def index # @locations = Location.find(:all, :conditions => ['name LIKE ?', params[:q] || '']) @locations = Location.search(params[:q]) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @locations } end end # GET /locations/1 # GET /locations/1.xml def show # @location = Location.find(params[:id]) # # respond_to do |format| # format.html # format.xml { render :xml => @location } # end @posts = Post.find(:all, :order => 'created_at DESC', :conditions => ["status = 'published'"]) @location = Location.find(params[:id]) end # GET /locations/new # GET /locations/new.xml def new @location = Location.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @location } end end # GET /locations/1/edit def edit @location = Location.find(params[:id]) end # POST /locations # POST /locations.xml def create @location = Location.new(params[:location]) respond_to do |format| if @location.save flash[:notice] = 'Location was successfully created.' format.html { redirect_to(@location) } format.xml { render :xml => @location, :status => :created, :location => @location } else format.html { render :action => "new" } format.xml { render :xml => @location.errors, :status => :unprocessable_entity } end end end # PUT /locations/1 # PUT /locations/1.xml def update @location = Location.find(params[:id]) respond_to do |format| if @location.update_attributes(params[:location]) flash[:notice] = 'Location was successfully updated.' format.html { redirect_to(@location) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @location.errors, :status => :unprocessable_entity } end end end # DELETE /locations/1 # DELETE /locations/1.xml def destroy @location = Location.find(params[:id]) @location.destroy respond_to do |format| format.html { redirect_to(locations_url) } format.xml { head :ok } end end end