Skip to content

Dev#35

Open
rpinoon wants to merge 8 commits intomainfrom
dev
Open

Dev#35
rpinoon wants to merge 8 commits intomainfrom
dev

Conversation

@rpinoon
Copy link
Copy Markdown
Owner

@rpinoon rpinoon commented Sep 14, 2022

so I made a seperate serializer for when the data is just a single object because it needs to be handled differently.
I tried making a serializer function with an 'if-block' or a ternary function that would accept any data and act accordingly but I was unsuccessful.
please let me know if there is a better way to do this.

also added attribute aliases for readability when it comes to the frontend

@mikodagatan
Copy link
Copy Markdown

Please add a proper title. It's practically a short gist of what's being done, shorter than the description.

@rpinoon
Copy link
Copy Markdown
Owner Author

rpinoon commented Sep 14, 2022

Please add a proper title. It's practically a short gist of what's being done, shorter than the description.

I'll make sure to do so on future PR's. thank you for reminding!

Copy link
Copy Markdown

@mikodagatan mikodagatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

validates :cover_image_url, presence: true
end No newline at end of file

alias_attribute :book_id, :id
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for? Why is the primary id of the Book table called book_id?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for the Book component in the frontend, which is being used by three other components. it initially looked like this
image

where in the Discover component, the books are from the Book controller itself so the 'id' there in the addToList() would refer to the book itself.

whereas in the ReadingList/FinishedList components, the books come from the UserBook controller, so the 'id' in the markBook() and removeBook() refers to the UserBook.

I thought this would be confusing if someone else read the code thats why I opted to change the names

Now that I think about it though, it was unecessary to use the alias on the book model itself since Book.id would make a lot more sense in the frontend and the one that actually needs to be aliased would be the UserBook id, that way it will read as Book.user_book_id

Am I on the right track here? or is there a better way of doing this

@rpinoon rpinoon requested review from mikodagatan and normancapule and removed request for mikodagatan and normancapule September 14, 2022 09:41
@normancapule
Copy link
Copy Markdown

Approving just to remove this from my PR list :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants