-
Notifications
You must be signed in to change notification settings - Fork 6
Books admin #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Books admin #66
Conversation
|
Still in development, but pull and test if you want |
| @@ -0,0 +1,4 @@ | |||
| class MakeBookOwnerNotNull < ActiveRecord::Migration[7.1] | |||
| def change | |||
| end | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migration is empty 🙃
| @@ -0,0 +1,5 @@ | |||
| class AddOwnerToBooks < ActiveRecord::Migration[7.1] | |||
| def change | |||
| add_reference :books, :owner, foreign_key: { to_table: :users } | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is normal rails way to tie 2 tables together, but we don't want admin users to own books, we just want books to have a list of editors. An array of strings would be good, or maybe a jsonb field to have e.g. {"regan" => "regan.ryan.nz@gmail.com"} yea that's better because then we can list the names of the owners, since some people have weird emails
app/controllers/songs_controller.rb
Outdated
| # become the chorus for this tune" | ||
| end | ||
|
|
||
| def song_diff(old_lyrics, new_lyrics, context_lines: 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to do git rebase -i master and drop the email commit, since it's not part of this feature
app/models/book.rb
Outdated
| songs: songs, | ||
| languages: languages | ||
| languages: languages, | ||
| admin: owner_id || [71], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User.system_user.id would be much better than "71"
Also you have "integer OR array" which might lead to problems.
But yea I think would be good to shift to jsonb as per another comment somewhere
http://localhost:3000/books/admin