AutoCommit Sam Jun 20 13:03:01 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-06-20 13:03:01 +02:00
parent 6e05c3d589
commit 67404cc605
3 changed files with 26 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
require 'flagable'
ActionController::Base.send :include, Flagable::ActsAsFlagable

View File

@@ -0,0 +1,14 @@
class AddFlagsToBeispiel < ActiveRecord::Migration
def change
add_column :beispiele, :flag_badquality, :boolean
add_column :beispiele, :flag_duplicate, :boolean
add_column :beispiele, :flag_delete, :boolean
add_column :beispiele, :flag_goodquality, :boolean
add_column :beispiele, :lecturer_id, :integer
add_index :beispiele, :flag_badquality
add_index :beispiele, :flag_duplicate
add_index :beispiele, :flag_delete
add_index :beispiele, :flag_goodquality
end
end

View File

@@ -13,13 +13,18 @@ module Flagable
module LocalInstanceMethods
def flag
@obj=controller_name.classify.constantize.find(params[:id])
text @obj.to_yaml
lflag=("flag_"+params[:flag]).to_sym
unless params[:flag].nil? || params[:flag].empty? || params[:value].nil?
@obj.try(lflag)#=params[:value]
@obj.send(lflag.to_s+"=",params[:value])
end
respond_to do |format|
format.html {render :text=>@obj.to_yaml}
format.js {render :text => "alert(#{lflag.to_s} #{@obj.to_yaml})"}
end
end
end
end
end
ActionController::Base.send :include, Flagable::ActsAsFlagable
ActionController.send :include, Flagable::ActsAsFlagable
ApplicationController.send :include, Flagable::ActsAsFlagable
BeispielController.send :include, Flagable::ActsAsFlagable