Project

General

Profile

Download (979 Bytes) Statistics
| Branch: | Tag: | Revision:
9eb0e160 Ohad Levy
class ModelsController < ApplicationController
97e387ca Ashay Humane
def index
d995ecb4 Paul Kelly
@search = Model.search params[:search]
@models = @search.paginate :page => params[:page]
97e387ca Ashay Humane
end

def new
@model = Model.new
end

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

def edit
@model = Model.find(params[:id])
end
72e65b31 Ohad Levy
97e387ca Ashay Humane
def update
@model = Model.find(params[:id])
if @model.update_attributes(params[:model])
flash[:foreman_notice] = "Successfully updated model."
redirect_to models_url
else
render :action => 'edit'
end
6e50fa1d Ohad Levy
end

97e387ca Ashay Humane
def destroy
@model = Model.find(params[:id])
if @model.destroy
flash[:foreman_notice] = "Successfully destroyed model."
else
be96f201 Ohad Levy
flash[:foreman_error] = @model.errors.full_messages.join("<br/>")
97e387ca Ashay Humane
end
redirect_to models_url
end
6e50fa1d Ohad Levy
end