Revision 5f6b2196
Added by Paul Kelly about 14 years ago
- ID 5f6b2196e7bb3283bc2a294cdeba8b59f088812c
app/controllers/environments_controller.rb | ||
---|---|---|
class EnvironmentsController < ApplicationController
|
||
active_scaffold :environment do |config|
|
||
config.columns = %w{name}
|
||
config.nested.add_link("Hosts", [:hosts])
|
||
config.nested.add_link("Classes", [:puppetclasses])
|
||
def index
|
||
@search = Environment.search(params[:search])
|
||
@environments = @search.paginate :page => params[:page]
|
||
end
|
||
|
||
def show
|
||
@environment = Environment.find(params[:id])
|
||
end
|
||
|
||
def new
|
||
@environment = Environment.new
|
||
end
|
||
|
||
def create
|
||
@environment = Environment.new(params[:environment])
|
||
if @environment.save
|
||
flash[:foreman_notice] = "Successfully created environment."
|
||
redirect_to environments_path
|
||
else
|
||
render :action => 'new'
|
||
end
|
||
end
|
||
|
||
def edit
|
||
@environment = Environment.find(params[:id])
|
||
end
|
||
|
||
config.action_links.add 'import_classes_and_environments', :label => 'Import environments and classes', :inline => false,
|
||
:page => :true , :type => :table
|
||
def update
|
||
@environment = Environment.find(params[:id])
|
||
if @environment.update_attributes(params[:environment])
|
||
flash[:foreman_notice] = "Successfully updated environment."
|
||
redirect_to environments_path
|
||
else
|
||
render :action => 'edit'
|
||
end
|
||
end
|
||
|
||
def destroy
|
||
@environment = Environment.find(params[:id])
|
||
if @environment.destroy
|
||
flash[:foreman_notice] = "Successfully destroyed '#{@environment.name}''"
|
||
else
|
||
flash[:foreman_error] = @environment.errors.full_messages.join("<br>")
|
||
end
|
||
redirect_to environments_url
|
||
end
|
||
|
||
end
|
Also available in: Unified diff
Fixes #204 - Remove AS from environments page
Merged import facility in Environment and Puppetclass controllers