forked from bofh/fetsite
AutoCommit Don Jun 25 16:03:19 CEST 2015
This commit is contained in:
@@ -36,6 +36,22 @@ class BeispieleController < ApplicationController
|
|||||||
end
|
end
|
||||||
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
|
# GET /beispiele/1/edit
|
||||||
def edit
|
def edit
|
||||||
@beispiel = Beispiel.find(params[:id])
|
@beispiel = Beispiel.find(params[:id])
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
|
|
||||||
class Beispiel < ActiveRecord::Base
|
class Beispiel < ActiveRecord::Base
|
||||||
has_paper_trail
|
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_votable
|
||||||
acts_as_flagable
|
acts_as_flagable
|
||||||
belongs_to :lva
|
belongs_to :lva
|
||||||
|
belongs_to :lecturer
|
||||||
FLAG_ICONS = {"badquality"=>"fa fa-flag","goodquality"=>"fa fa-flag", "delete"=>"fa fa-trash"}
|
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 :not_flag_badquality, ->{where("flag_badquality IS NULL OR flag_badquality=?",false)}
|
||||||
scope :flag_badquality, ->{where("flag_badquality=?",true)}
|
scope :flag_badquality, ->{where("flag_badquality=?",true)}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<%= f.input :desc %>
|
<%= f.input :desc %>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
<%= f.input :lva, :as=>:radio, :collection => Lva.all %>
|
<%= f.input :lecturer, :as=>:select, :collection => @beispiel.lva.lecturers %>
|
||||||
</div>
|
</div>
|
||||||
<%= f.hidden_field :beispieldatei_cache %>
|
<%= f.hidden_field :beispieldatei_cache %>
|
||||||
<%= f.actions do %>
|
<%= f.actions do %>
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
get 'like'
|
get 'like'
|
||||||
get 'dislike'
|
get 'dislike'
|
||||||
get 'flag'
|
get 'flag'
|
||||||
|
get 'set_lecturer'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :lvas do
|
resources :lvas do
|
||||||
|
|||||||
Reference in New Issue
Block a user