forked from bofh/fetsite
AutoCommit Sam Jun 20 13:03:01 CEST 2015
This commit is contained in:
2
config/initializers/init_flagable.rb
Normal file
2
config/initializers/init_flagable.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
require 'flagable'
|
||||||
|
ActionController::Base.send :include, Flagable::ActsAsFlagable
|
||||||
14
db/migrate/20150620101949_add_flags_to_beispiel.rb
Normal file
14
db/migrate/20150620101949_add_flags_to_beispiel.rb
Normal 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
|
||||||
@@ -13,13 +13,18 @@ module Flagable
|
|||||||
module LocalInstanceMethods
|
module LocalInstanceMethods
|
||||||
def flag
|
def flag
|
||||||
@obj=controller_name.classify.constantize.find(params[:id])
|
@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
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user