merge cachebsp

This commit is contained in:
2015-06-26 11:08:44 +02:00
5 changed files with 23 additions and 4 deletions

View File

@@ -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])

View File

@@ -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)}

View File

@@ -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 %>

View File

@@ -103,6 +103,7 @@
<% if @beispiele_deleted.count > 0 %> <% if @beispiele_deleted.count > 0 %>
<h3> Trash</h3> <h3> Trash</h3>
<% @beispiele_deleted.each do |b| %> <% @beispiele_deleted.each do |b| %>
<% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s + "_" + can?(:flag, b).to_s + "_" + can?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %> <% cache("beispiel_" +I18n.locale.to_s+b.id.to_s+can?(:delete,b).to_s+"_"+can?(:edit,b).to_s + "_" + can?(:flag, b).to_s + "_" + can?(:like, b).to_s + "_" + b.updated_at.try(:utc).try(:to_s) + get_theme_help(current_user).to_s) do %>
<%= render b%> <%= render b%>
<% end %> <% end %>

View File

@@ -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