class HostsController < ApplicationController before_filter :login_required # GET /hosts # GET /hosts.xml def index @hosts = Host.find(:all) respond_to do |format| format.html # index.rhtml format.xml { render :xml => @hosts.to_xml } end end # GET /hosts/1 # GET /hosts/1.xml def show @host = Host.find(params[:id]) respond_to do |format| format.html # show.rhtml format.xml { render :xml => @host.to_xml } end end # GET /hosts/new def new @host = Host.new end # GET /hosts/1;edit def edit @host = Host.find(params[:id]) end # POST /hosts # POST /hosts.xml def create @host = Host.new(params[:host]) respond_to do |format| if @host.save flash[:notice] = 'Host was successfully created.' format.html { redirect_to host_url(@host) } format.xml do headers["Location"] = host_url(@host) render :nothing => true, :status => "201 Created" end else format.html { render :action => "new" } format.xml { render :xml => @host.errors.to_xml } end end end # PUT /hosts/1 # PUT /hosts/1.xml def update @host = Host.find(params[:id]) respond_to do |format| if @host.update_attributes(params[:host]) format.html { redirect_to host_url(@host) } format.xml { render :nothing => true } else format.html { render :action => "edit" } format.xml { render :xml => @host.errors.to_xml } end end end # DELETE /hosts/1 # DELETE /hosts/1.xml def destroy @host = Host.find(params[:id]) @host.destroy respond_to do |format| format.html { redirect_to hosts_url } format.xml { render :nothing => true } end end end