Project

General

Profile

Download (1.25 KB) Statistics
| Branch: | Tag: | Revision:
class DomainsController < ApplicationController
before_filter :find_domain, :only => %w{show edit update destroy}

def index
respond_to do |format|
format.html do
@search = Domain.search params[:search]
@domains = @search.paginate :page => params[:page], :include => 'hosts'
end
format.json { render :json => Domain.all }
end
end

def new
@domain = Domain.new
end

def show
respond_to do |format|
format.json { render :json => @domain }
end
end

def create
@domain = Domain.new(params[:domain])
if @domain.save
flash[:foreman_notice] = "Successfully created domain."
redirect_to domains_url
else
render :action => 'new'
end
end

def edit
end

def update
if @domain.update_attributes(params[:domain])
flash[:foreman_notice] = "Successfully updated domain."
redirect_to domains_url
else
render :action => 'edit'
end
end

def destroy
if @domain.destroy
flash[:foreman_notice] = "Successfully destroyed domain."
else
flash[:foreman_error] = @domain.errors.full_messages.join("<br/>")
end
redirect_to domains_url
end

private
def find_domain
@domain = Domain.find_by_name(params[:id])
end

end
(7-7/24)