This repository has been archived by the owner on Nov 22, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert ChapterNote#chapter_ids to string
Add spec for Chapters#index
- Loading branch information
Showing
7 changed files
with
46 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,6 @@ def validate | |
end | ||
|
||
def chapter_goods_id | ||
sprintf("%02d00000000", chapter_id) | ||
chapter_id.ljust('0', 10) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
collection @chapters | ||
attributes :goods_nomenclature_item_id | ||
node(:chapter_note_id) { |chapter| chapter.chapter_note.try(:id) } |
18 changes: 18 additions & 0 deletions
18
db/migrate/20130809075350_change_chapter_note_foreign_key_type.rb
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,18 @@ | ||
Sequel.migration do | ||
up do | ||
alter_table :chapter_notes do | ||
set_column_type :chapter_id, String, size: 2 | ||
end | ||
|
||
# prefix with leading zero chapters with id < 10 | ||
self[:chapter_notes].all do |chapter_note| | ||
self[:chapter_notes].filter(content: chapter_note[:content]).update(chapter_id: sprintf("%02d", chapter_note[:chapter_id].to_i)) | ||
end | ||
end | ||
|
||
down do | ||
alter_table :chapter_notes do | ||
set_column_type :chapter_id, Integer | ||
end | ||
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
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