forked from publiclab/plots2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First timer tag script (publiclab#4878)
* First timer tag script * migration for attaching first-time-poster * change migration bump version to 5.1 * Update schema.rb.example
- Loading branch information
1 parent
bb5feab
commit 8a1e487
Showing
2 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class AddFirstTagPoster < ActiveRecord::Migration[5.1] | ||
def find_and_update | ||
User.joins(:node).where('node.status = ?', 1).each do |user| | ||
if user.nodes.present? | ||
node = user.nodes.first | ||
node.add_tag('first-time-post', user) | ||
end | ||
end | ||
end | ||
|
||
def up | ||
find_and_update | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters