From 7fd75a7f3a36302809070faaef8cd4f4fb3ddb2b Mon Sep 17 00:00:00 2001 From: Robert J Samson Date: Wed, 19 Sep 2012 20:28:09 -0400 Subject: [PATCH] More descriptive method and attribute names --- app/models/tag.rb | 4 ++-- app/views/stories/_form.html.erb | 2 +- db/migrate/20120919195401_private_tags.rb | 6 +++--- db/schema.rb | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index c8f5456..447c312 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -6,11 +6,11 @@ class Tag < ActiveRecord::Base if user.is_admin? all else - where(:private => false) + where(:privileged => false) end end - def self.all_with_filtered_counts(user) + def self.all_with_filtered_counts_for(user) counts = TagFilter.count(:group => "tag_id") Tag.order(:tag).accessible_to(user).map{|t| diff --git a/app/views/stories/_form.html.erb b/app/views/stories/_form.html.erb index 11b2ae6..7213c86 100644 --- a/app/views/stories/_form.html.erb +++ b/app/views/stories/_form.html.erb @@ -24,7 +24,7 @@ <%= f.label :tags_a, "Tags:", :class => "required", :style => "line-height: 2.3em;" %> <%= 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("") + t.tag + raw(" - ") + t.description.to_s + (t.filtered_count == 0 ? "" : diff --git a/db/migrate/20120919195401_private_tags.rb b/db/migrate/20120919195401_private_tags.rb index 8352cc1..a8667eb 100644 --- a/db/migrate/20120919195401_private_tags.rb +++ b/db/migrate/20120919195401_private_tags.rb @@ -1,15 +1,15 @@ class PrivateTags < ActiveRecord::Migration def up - add_column :tags, :private, :boolean, :default => false + add_column :tags, :privileged, :boolean, :default => false # All existing tags should be public by default Tag.all.each do |t| - t.private = false + t.privileged = false t.save end end def down - remove_column :tags, :private + remove_column :tags, :privileged end end diff --git a/db/schema.rb b/db/schema.rb index 6797a05..65424a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -115,7 +115,7 @@ ActiveRecord::Schema.define(:version => 20120919195401) do t.string "tag", :limit => 25, :default => "", :null => false t.string "description", :limit => 100 t.boolean "filtered_by_default", :default => false - t.boolean "private", :default => false + t.boolean "privileged", :default => false end add_index "tags", ["tag"], :name => "tag", :unique => true