rosa-build/app/controllers/platforms_controller.rb

49 lines
1.1 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class PlatformsController < ApplicationController
before_filter :authenticate_user!
def index
@platforms = Platform.all
end
def show
@platform = Platform.find params[:id], :include => :projects
@projects = @platform.projects
end
def new
@platforms = Platform.all
@platform = Platform.new
end
def edit
@platform = Platform.find params[:id]
end
def create
@platform = Platform.new params[:platform]
if @platform.save
flash[:notice] = 'Платформа успешно добавлена'
redirect_to @platform
else
flash[:error] = 'Не удалось создать платформу'
render :action => :new
end
end
def update
@platform = Platform.find params[:id]
if @platform.update_attributes(params[:platform])
flash[:notice] = 'Платформа успешно обновлена'
redirect_to @platform
else
flash[:error] = 'Не удалось обновить платформу'
render :action => :edit
end
end
def destroy
Platform.destroy params[:id]
redirect_to root_path
end
end