diff --git a/app/controllers/beispiele_controller.rb b/app/controllers/beispiele_controller.rb index 7c75fa5..1bfd478 100755 --- a/app/controllers/beispiele_controller.rb +++ b/app/controllers/beispiele_controller.rb @@ -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]) diff --git a/app/models/beispiel.rb b/app/models/beispiel.rb index 24a0f7b..4725133 100755 --- a/app/models/beispiel.rb +++ b/app/models/beispiel.rb @@ -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)} diff --git a/app/views/beispiele/_form.html.erb b/app/views/beispiele/_form.html.erb index 4526e7c..ef9f727 100755 --- a/app/views/beispiele/_form.html.erb +++ b/app/views/beispiele/_form.html.erb @@ -24,7 +24,7 @@ <%= f.input :desc %>