foreman/app/controllers/models_controller.rb @ acfbc458
9eb0e160 | Ohad Levy | class ModelsController < ApplicationController
|
|
8104eced | Ohad Levy | include Foreman::Controller::AutoCompleteSearch
|
|
acfbc458 | Marek Hulan | before_filter :find_by_name, :only => [:edit, :update, :destroy]
|
|
8104eced | Ohad Levy | ||
97e387ca | Ashay Humane | def index
|
|
acfbc458 | Marek Hulan | @models = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
|
|
145db863 | Dmitri Dolguikh | @host_counter = Host.group(:model_id).where(:model_id => @models.select(&:id)).count
|
|
97e387ca | Ashay Humane | end
|
|
def new
|
|||
@model = Model.new
|
|||
end
|
|||
def create
|
|||
@model = Model.new(params[:model])
|
|||
if @model.save
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
97e387ca | Ashay Humane | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
97e387ca | Ashay Humane | end
|
|
end
|
|||
def edit
|
|||
end
|
|||
72e65b31 | Ohad Levy | ||
97e387ca | Ashay Humane | def update
|
|
if @model.update_attributes(params[:model])
|
|||
b28fdce4 | Ohad Levy | process_success
|
|
97e387ca | Ashay Humane | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
97e387ca | Ashay Humane | end
|
|
6e50fa1d | Ohad Levy | end
|
|
97e387ca | Ashay Humane | def destroy
|
|
9fd7478e | Paul Kelly | if @model.destroy
|
|
b28fdce4 | Ohad Levy | process_success
|
|
97e387ca | Ashay Humane | else
|
|
b28fdce4 | Ohad Levy | process_error
|
|
97e387ca | Ashay Humane | end
|
|
end
|
|||
acfbc458 | Marek Hulan | ||
6e50fa1d | Ohad Levy | end
|