Skip to content

Commit 033c015

Browse files
committed
Additional fixes in controllers
There were a few leftovers from rocket_tag in the networks, opportunities and protips controllers. + indentation fix on migration
1 parent c7028f9 commit 033c015

7 files changed

+22
-35
lines changed

Gemfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ gem 'foreman'
9494
# Better logging
9595
gem 'awesome_print'
9696

97+
# Tagging
98+
gem 'acts-as-taggable-on', '~> 3.4'
99+
97100
gem 'faraday', '~> 0.8.1'
98101
gem 'metamagic'
99102

@@ -135,12 +138,6 @@ gem 'mongoid'
135138
gem 'mongo'
136139
gem 'mongoid_taggable'
137140
gem 'bson_ext'
138-
#Tagging
139-
gem 'rocket_tag'
140-
gem 'squeel', '1.0.1'
141-
142-
gem 'acts-as-taggable-on', '~> 3.4'
143-
144141
gem 'strong_parameters'
145142
gem 'postgres_ext'
146143
# ElasticSearch client

Gemfile.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,6 @@ GEM
477477
cliver (~> 0.3.1)
478478
multi_json (~> 1.0)
479479
websocket-driver (>= 0.2.0)
480-
polyamorous (0.5.0)
481-
activerecord (~> 3.0)
482480
polyglot (0.3.5)
483481
poro_plus (1.0.2)
484482
posix-spawn (0.3.9)
@@ -595,9 +593,6 @@ GEM
595593
rest-client (1.7.2)
596594
mime-types (>= 1.16, < 3.0)
597595
netrc (~> 0.7)
598-
rocket_tag (0.5.6)
599-
activerecord (>= 3.2.0)
600-
squeel (~> 1.0.0)
601596
rspec (3.1.0)
602597
rspec-core (~> 3.1.0)
603598
rspec-expectations (~> 3.1.0)
@@ -690,10 +685,6 @@ GEM
690685
multi_json (~> 1.0)
691686
rack (~> 1.0)
692687
tilt (~> 1.1, != 1.3.0)
693-
squeel (1.0.1)
694-
activerecord (~> 3.0)
695-
activesupport (~> 3.0)
696-
polyamorous (~> 0.5.0)
697688
strong_parameters (0.2.3)
698689
actionpack (~> 3.0)
699690
activemodel (~> 3.0)
@@ -858,7 +849,6 @@ DEPENDENCIES
858849
redcarpet
859850
redis-rails (~> 3.2)
860851
rest-client
861-
rocket_tag
862852
rspec-rails
863853
rubocop
864854
ruby-progressbar
@@ -875,7 +865,6 @@ DEPENDENCIES
875865
slim-rails
876866
spring
877867
spring-commands-rspec
878-
squeel (= 1.0.1)
879868
stripe!
880869
stripe-ruby-mock!
881870
strong_parameters

app/controllers/networks_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def members
4141

4242
def show
4343
@protips = []
44-
@topics = @network.tags
44+
@topics = @network.tag_list
4545

4646
if (params[:sort].blank? && params[:filter].blank?) || params[:sort] == 'upvotes'
4747
@protips = @network.most_upvoted_protips(@per_page, @page)
@@ -141,7 +141,7 @@ def destroy
141141

142142
def add_tag
143143
tag = params[:tag]
144-
@network.tags << tag
144+
@network.tag_list.add(tag)
145145

146146
respond_to do |format|
147147
if @network.save
@@ -155,8 +155,8 @@ def add_tag
155155
end
156156

157157
def remove_tag
158-
tag = params[:tag]
159-
@network.tags = @network.tags.delete(tag)
158+
tag = params[:tag]
159+
@network.tag_list.remove(tag)
160160

161161
respond_to do |format|
162162
if @network.save
@@ -171,7 +171,7 @@ def remove_tag
171171

172172
def update_tags
173173
tags = params[:tags][:tags]
174-
@network.tags = tags.split(',').map(&:strip).select { |tag| Tag.exists?(name: tag) }
174+
@network.tag_list = tags.split(',').map(&:strip).select { |tag| Tag.exists?(name: tag) }
175175

176176
respond_to do |format|
177177
if @network.save

app/controllers/opportunities_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class OpportunitiesController < ApplicationController
22
before_action :lookup_team, only: [:activate, :deactivate, :new, :create, :edit, :update, :visit]
33
before_action :lookup_opportunity, only: [:edit, :update, :activate, :deactivate, :visit]
4-
before_action :cleanup_params_to_prevent_rocket_tag_error
4+
before_action :cleanup_params_to_prevent_tagging_error
55
before_action :validate_permissions, only: [:new, :edit, :create, :update, :activate, :deactivate]
66
before_action :verify_payment, only: [:new, :create]
77
before_action :stringify_location, only: [:create, :update]
@@ -131,10 +131,10 @@ def header_ok
131131
end
132132
end
133133

134-
def cleanup_params_to_prevent_rocket_tag_error
135-
if params[:opportunity] && params[:opportunity][:tags]
136-
params[:opportunity][:tags] = "#{params[:opportunity][:tags]}".split(',').map(&:strip).reject(&:empty?).join(",")
137-
params[:opportunity][:tags] = nil if params[:opportunity][:tags].strip.blank?
134+
def cleanup_params_to_prevent_tagging_error
135+
if params[:opportunity] && params[:opportunity][:tag_list]
136+
params[:opportunity][:tag_list] = "#{params[:opportunity][:tag_list]}".split(',').map(&:strip).reject(&:empty?).join(",")
137+
params[:opportunity][:tag_list] = nil if params[:opportunity][:tag_list].strip.blank?
138138
end
139139
end
140140

@@ -151,7 +151,7 @@ def all_job_locations
151151
end
152152

153153
def all_job_skills
154-
Rails.cache.fetch('job_skills', expires_in: 23.hours) { Opportunity.all.flat_map(&:tags).uniq.compact }
154+
Rails.cache.fetch('job_skills', expires_in: 23.hours) { Opportunity.all.flat_map(&:tag_list).uniq.compact }
155155
end
156156

157157
def closest_to_user(user)

app/controllers/protips_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def create
187187
def update
188188
# strong_parameters will intentionally fail if a key is present but has an empty hash. :(
189189
update_params = if params[:protip] && params[:protip].keys.present?
190-
params.require(:protip).permit(:title, :body, :user_id, topic_list: [])
190+
params.require(:protip).permit(:title, :body, :user_id, :topic_list)
191191
else
192192
{}
193193
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# Replace this with default parser before upgrading to AATO 4.0+
12
ActsAsTaggableOn.delimiter = [' ', ',']
23
ActsAsTaggableOn.force_lowercase = true

db/migrate/20141231203425_replace_rocket_tag_with_aato.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class ReplaceRocketTagWithAato < ActiveRecord::Migration
22
def up
3-
# This was created by rocket_tag but not used anywhere.
4-
drop_table :alias_tags
3+
# This was created by rocket_tag but not used anywhere.
4+
drop_table :alias_tags
55

6-
# This is something that AATO has that rocket_tag doesn't.
7-
add_column :tags, :taggings_count, :integer, default: 0
6+
# This is something that AATO has that rocket_tag doesn't.
7+
add_column :tags, :taggings_count, :integer, default: 0
88

9-
# Populate the taggings_count properly
9+
# Populate the taggings_count properly
1010
ActsAsTaggableOn::Tag.reset_column_information
1111
ActsAsTaggableOn::Tag.find_each do |tag|
1212
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
@@ -22,6 +22,6 @@ def up
2222
end
2323

2424
def down
25-
raise ActiveRecord::IrreversibleMigration
25+
raise ActiveRecord::IrreversibleMigration
2626
end
2727
end

0 commit comments

Comments
 (0)