Hi I am working on a project where I have a Process object that references a Node object. I have tried adding a node_id column in the Process table and created an has_one relationship in the Process model. When trying Process.node.create(@attr) am getting an error as the sql is trying to update the process_id column in the Node table. I dont want to add a process_id column in the node table as most nodes will not refer to a process (ie one way association between process and node). Any ideas? Cheers jason -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 June 2012 16:45, Jason Walsh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > > I am working on a project where I have a Process object that references > a Node object. I have tried adding a node_id column in the Process > table and created an has_one relationship in the Process model.If you have node_id in Process then you want process belongs_to node. Have a look at the Rails Guide on ActiveRecord Associations for more information. Colin> > When trying Process.node.create(@attr) am getting an error as the sql is > trying to update the process_id column in the Node table. I dont want > to add a process_id column in the node table as most nodes will not > refer to a process (ie one way association between process and node). > > Any ideas? > > Cheers > > jason > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 June 2012 16:45, Jason Walsh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am working on a project where I have a Process object that references > a Node object. I have tried adding a node_id column in the Process > table and created an has_one relationship in the Process model.Change that relationship definition to a belongs_to rather than a has_one. http://guides.rubyonrails.org/association_basics.html -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 June 2012 17:35, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9 June 2012 16:45, Jason Walsh <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> I am working on a project where I have a Process object that references >> a Node object. I have tried adding a node_id column in the Process >> table and created an has_one relationship in the Process model. > > Change that relationship definition to a belongs_to rather than a has_one. > > http://guides.rubyonrails.org/association_basics.html@Michael, perhaps we should work in shifts. Colin> > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 June 2012 17:51, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> @Michael, perhaps we should work in shifts. > > Colin:-D -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote in post #1063859:> On 9 June 2012 17:51, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> @Michael, perhaps we should work in shifts. >> >> Colin > > :-DThanks fellas - that did the trick :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.