Skip to content

Using one to serialize an active record serialized field #203

Answered by okuramasafumi
bernardeli asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

I got the following working but feels odd to use one when that is not a relationship.

It can be read as "Product has one price." Personally it's acceptable, but if you want to avoid that then you could use the code like you posted later.

How can I use one/many for relationships but change the relationship name?

You can add key option to one method to change its key. See https://rubydoc.info/gems/alba/Alba/Resource/ClassMethods#association-instance_method
(Sorry that it's not in README, I'll add the mention to it)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bernardeli
Comment options

Answer selected by bernardeli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants