AutoCommit Don Jun 25 16:03:19 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-06-25 16:03:20 +02:00
parent b9d436789c
commit 88877ccab0
4 changed files with 20 additions and 2 deletions

View File

@@ -36,6 +36,22 @@ class BeispieleController < ApplicationController
end
end
def set_lecturer
@beispiel = Beispiel.find(params[:id])
@beispiel.lecturer = Lecturer.find(params[:beispiel][:lecturer_id])
@beispiel.save
if @beispiel.save
format.html { redirect_to @backlink, notice: 'Beispiel was successfully updated.' }
format.js {render text: "alert(\"updated\");"}
format.json { head :no_content }
else
format.html { render action: "edit" }
format.js
format.json { render json: @beispiel.errors, status: :unprocessable_entity }
end
end
# GET /beispiele/1/edit
def edit
@beispiel = Beispiel.find(params[:id])

View File

@@ -13,10 +13,11 @@
class Beispiel < ActiveRecord::Base
has_paper_trail
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache, :datum, :lecturer_id
acts_as_votable
acts_as_flagable
belongs_to :lva
belongs_to :lecturer
FLAG_ICONS = {"badquality"=>"fa fa-flag","goodquality"=>"fa fa-flag", "delete"=>"fa fa-trash"}
scope :not_flag_badquality, ->{where("flag_badquality IS NULL OR flag_badquality=?",false)}
scope :flag_badquality, ->{where("flag_badquality=?",true)}

View File

@@ -24,7 +24,7 @@
<%= f.input :desc %>
</div>
<div class="span4">
<%= f.input :lva, :as=>:radio, :collection => Lva.all %>
<%= f.input :lecturer, :as=>:select, :collection => @beispiel.lva.lecturers %>
</div>
<%= f.hidden_field :beispieldatei_cache %>
<%= f.actions do %>

View File

@@ -74,6 +74,7 @@
get 'like'
get 'dislike'
get 'flag'
get 'set_lecturer'
end
end
resources :lvas do