web/app/controllers/settings/runtimes_controller.rb
changeset 106 eac4098d544d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/app/controllers/settings/runtimes_controller.rb	Tue Jun 25 22:11:10 2013 +0200
@@ -0,0 +1,51 @@
+class Settings::RuntimesController < SettingsController
+
+  def index
+    @runtime = Runtime.new
+  end
+
+  def show
+    @runtime = Runtime.find(params[:id])
+  end
+
+  def create
+    @runtime = Runtime.new(runtime_params)
+
+    if @runtime.save
+      flash[:success] = "Runtime #{@runtime.name} successfully created"
+      redirect_to action: :index
+    else
+      flash.now[:failure] = "There were some errors" 
+      render "index"
+    end
+  end
+  def update
+    @runtime = Runtime.find(params[:id])
+
+    if @runtime.update_attributes(runtime_params)
+      flash[:success] = "Runtime #{@runtime.name} successfully updated"
+      redirect_to action: :index
+    else
+      flash.now[:failure] = "There were some errors" 
+      render "index"
+    end
+  end
+
+  def destroy
+    @runtime = Runtime.find(params[:id])
+
+    if @runtime.destroy
+      flash[:success] = "Runtime #{@runtime.name} successfully deleted"
+    else
+      flash[:error] = "Could not delete #{@runtime.name} runtime"
+    end
+
+    redirect_to action: :index
+  end
+
+  private
+
+  def runtime_params
+    params.require(:runtime).permit(:name, :language_id)
+  end
+end