Skip to content

Commit

Permalink
More descriptive method and attribute names
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsamson committed Sep 20, 2012
1 parent 5ada55f commit 7fd75a7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/models/tag.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion app/views/stories/_form.html.erb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 ? "" :
Expand Down
6 changes: 3 additions & 3 deletions db/migrate/20120919195401_private_tags.rb
Original file line number Original file line Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
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
Expand Down

0 comments on commit 7fd75a7

Please sign in to comment.