More descriptive method and attribute names
This commit is contained in:
parent
5ada55f10d
commit
7fd75a7f3a
|
@ -6,11 +6,11 @@ class Tag < ActiveRecord::Base
|
||||||
if user.is_admin?
|
if user.is_admin?
|
||||||
all
|
all
|
||||||
else
|
else
|
||||||
where(:private => false)
|
where(:privileged => false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.all_with_filtered_counts(user)
|
def self.all_with_filtered_counts_for(user)
|
||||||
counts = TagFilter.count(:group => "tag_id")
|
counts = TagFilter.count(:group => "tag_id")
|
||||||
|
|
||||||
Tag.order(:tag).accessible_to(user).map{|t|
|
Tag.order(:tag).accessible_to(user).map{|t|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<%= f.label :tags_a, "Tags:", :class => "required",
|
<%= f.label :tags_a, "Tags:", :class => "required",
|
||||||
:style => "line-height: 2.3em;" %>
|
:style => "line-height: 2.3em;" %>
|
||||||
<%= f.select "tags_a", options_for_select(
|
<%= f.select "tags_a", options_for_select(
|
||||||
Tag.all_with_filtered_counts(@user).map{|t|
|
Tag.all_with_filtered_counts_for(@user).map{|t|
|
||||||
[ "#{t.tag} - #{t.description}", t.tag, { "data-html" => raw("<strong>") +
|
[ "#{t.tag} - #{t.description}", t.tag, { "data-html" => raw("<strong>") +
|
||||||
t.tag + raw("</strong> - ") + t.description.to_s +
|
t.tag + raw("</strong> - ") + t.description.to_s +
|
||||||
(t.filtered_count == 0 ? "" :
|
(t.filtered_count == 0 ? "" :
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
class PrivateTags < ActiveRecord::Migration
|
class PrivateTags < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
add_column :tags, :private, :boolean, :default => false
|
add_column :tags, :privileged, :boolean, :default => false
|
||||||
|
|
||||||
# All existing tags should be public by default
|
# All existing tags should be public by default
|
||||||
Tag.all.each do |t|
|
Tag.all.each do |t|
|
||||||
t.private = false
|
t.privileged = false
|
||||||
t.save
|
t.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
remove_column :tags, :private
|
remove_column :tags, :privileged
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -115,7 +115,7 @@ ActiveRecord::Schema.define(:version => 20120919195401) do
|
||||||
t.string "tag", :limit => 25, :default => "", :null => false
|
t.string "tag", :limit => 25, :default => "", :null => false
|
||||||
t.string "description", :limit => 100
|
t.string "description", :limit => 100
|
||||||
t.boolean "filtered_by_default", :default => false
|
t.boolean "filtered_by_default", :default => false
|
||||||
t.boolean "private", :default => false
|
t.boolean "privileged", :default => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "tags", ["tag"], :name => "tag", :unique => true
|
add_index "tags", ["tag"], :name => "tag", :unique => true
|
||||||
|
|
Loading…
Reference in a new issue