belongs_to without has_many ?

24 views
Skip to first unread message

fugee ohu

unread,
Feb 12, 2018, 9:33:59 PM2/12/18
to Ruby on Rails: Talk
I'm trying to add a model abstraction in between two existing but the top is just the model, User in my case, in the main app that gets the line "blog" placed in it and then inside the gem posts belongs to blogger but there's no blogger model like  I said I wanna let bloggers have_one blog_setting so they can put the title description, theme in database tables

Walter Lee Davis

unread,
Feb 12, 2018, 10:16:29 PM2/12/18
to rubyonra...@googlegroups.com
You can balance belongs_to with has_one or has_many. You have to pick one of those two options, otherwise it's not appropriate for a belongs_to.

Walter

> On Feb 12, 2018, at 9:33 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> I'm trying to add a model abstraction in between two existing but the top is just the model, User in my case, in the main app that gets the line "blog" placed in it and then inside the gem posts belongs to blogger but there's no blogger model like I said I wanna let bloggers have_one blog_setting so they can put the title description, theme in database tables
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/67ea4dd0-908c-490d-98e6-106918c19b3b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Feb 13, 2018, 3:55:18 AM2/13/18
to Ruby on Rails: Talk
On 13 February 2018 at 03:15, Walter Lee Davis <wa...@wdstudio.com> wrote:
You can balance belongs_to with has_one or has_many. You have to pick one of those two options, otherwise it's not appropriate for a belongs_to.

Conceptually yes, but I suspect that if you had A belongs_to B but did not actually specify B has_nnn A that one could go ahead and use the belongs_to methods such as @a.b provided one never tried to use @b.a or any of the methods associated with that.  I may be wrong though, and I can't see any reason not to put the has_nnn in.

However I am not sure that is what fugee is actually asking. I am having difficulty reconciling the subject line with the content of the post, or even understanding what the post is trying to ask.

You certainly can't have a B has_nnn A without the reciprocal belongs_to though.

Colin
 

Walter

> On Feb 12, 2018, at 9:33 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> I'm trying to add a model abstraction in between two existing but the top is just the model, User in my case, in the main app that gets the line "blog" placed in it and then inside the gem posts belongs to blogger but there's no blogger model like  I said I wanna let bloggers have_one blog_setting so they can put the title description, theme in database tables
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/707460E0-B12A-4D2C-BBFA-DD130FC5D8FE%40wdstudio.com.
Reply all
Reply to author
Forward
0 new messages