-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
position
field to books (#1593)
* Add a `position` field to books backfill script: This script isn't that important as we can always manually fiddle with the positions in production ```ruby BOOK_SLUGS_IN_ORDER = %w[no-wall-they-can-build from-democracy-to-freedom contradictionary work expect-resistance recipes-for-disaster days-of-war-nights-of-love off-the-map no-habra-muro-que-nos-pare da-democracia-a-liberdade trabalho-edicao-resumida-de-emergencia espere-resistencia receitas-para-o-desastre dias-de-guerra-noites-de-amor].freeze BOOK_SLUGS_IN_ORDER.each_with_index do |slug, index| Book.find_by(slug: slug)&.update!(position: index) end ``` resolves #1446
- Loading branch information
1 parent
f3cb7f8
commit c26a5ed
Showing
7 changed files
with
37 additions
and
28 deletions.
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
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
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
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
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,4 @@ | ||
<div id="position" class="form-group"> | ||
<%= form.label :position, "Position this book on the index page" %> | ||
<%= number_field :book, :position, step: 1, class: 'form-control' %> | ||
</div><!-- #position --> |
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,11 @@ | ||
class AddPositionToBooks < ActiveRecord::Migration[6.0] | ||
def up | ||
add_column :books, :position, :integer | ||
add_column :books, :hide_from_index, :boolean, default: false | ||
end | ||
|
||
def down | ||
remove_column :books, :position, :integer | ||
remove_column :books, :hide_from_index, :boolean, default: false | ||
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