hi all there are two tables Student and Batch in there model i have has_and_belongs_to_many :graduated_batches, :class_name => ''Batch'', :join_table => ''batch_students'' in Student table and has_and_belongs_to_many :graduated_students, :class_name => ''Student'', :join_table => ''batch_students'' in Batch table which are connected to a table called "batch_students" i have added a new column to batch_students table and i want to update the value in batch_students table. How can i update values in batch_students table where there is no model for that table so that i can update directly.how to update table which is in joins. thanks in advance -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/18DSkbKNyBQJ. 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
2012-Jun-12 09:32 UTC
Re: how to update a table which is connected with joins
On 12 June 2012 10:31, honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hi all there are two tables Student and Batch in there model i have > has_and_belongs_to_many :graduated_batches, :class_name => ''Batch'', > :join_table => ''batch_students'' in Student table > i have added a new column to batch_students table and i want to update the > value in batch_students table. How can i update values in batch_students > table where there is no model for that table so that i can update > directly.how to update table which is in joins.Sounds like you want to change those habtm relationships to "has_many :through => :batch_students" -- 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.
hanish jadala
2012-Jun-12 09:37 UTC
Re: how to update a table which is connected with joins
no with our changing the relationship can i update values. thanks in advance On Tue, Jun 12, 2012 at 3:02 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 12 June 2012 10:31, honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hi all there are two tables Student and Batch in there model i have > > has_and_belongs_to_many :graduated_batches, :class_name => ''Batch'', > > :join_table => ''batch_students'' in Student table > > i have added a new column to batch_students table and i want to update > the > > value in batch_students table. How can i update values in batch_students > > table where there is no model for that table so that i can update > > directly.how to update table which is in joins. > > > Sounds like you want to change those habtm relationships to "has_many > :through => :batch_students" > > -- > 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. > >-- 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.
hanish jadala
2012-Jun-13 07:31 UTC
Re: how to update a table which is connected with joins
hi all help me out guys thanks in advance On Tue, Jun 12, 2012 at 3:07 PM, hanish jadala <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> no with our changing the relationship can i update values. > > > thanks in advance > > > On Tue, Jun 12, 2012 at 3:02 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> On 12 June 2012 10:31, honey ruby <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > >> > hi all there are two tables Student and Batch in there model i have >> > has_and_belongs_to_many :graduated_batches, :class_name => ''Batch'', >> > :join_table => ''batch_students'' in Student table >> > i have added a new column to batch_students table and i want to update >> the >> > value in batch_students table. How can i update values in batch_students >> > table where there is no model for that table so that i can update >> > directly.how to update table which is in joins. >> >> >> Sounds like you want to change those habtm relationships to "has_many >> :through => :batch_students" >> >> -- >> 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. >> >> >-- 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.
How about: http://abdul-barek-rails.blogspot.com/2009/12/how-to-execute-sql-query-in-rails.html I didn''t tried it, but you may probably write Students.execute(''update anytable set .....'') by TheR -- 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.
Michael Pavling
2012-Jun-13 08:21 UTC
Re: how to update a table which is connected with joins
On 13 June 2012 08:31, hanish jadala <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi all help me out guys > > > thanks in advance > > On Tue, Jun 12, 2012 at 3:07 PM, hanish jadala <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> >> no with our changing the relationship can i update values.We did - you refused to do it :-/ Let''s just restate your position: You want to have a habtm join, with extra information in the join table. This type of join typically does not have a model, and thus no way of updating those extra fields (although a "feature" of Rails does/did extend columns in the join table to both sides of the association). You don''t want to add a new model and join through it (the way it would be done normally). So you see the circular problem you have... Let''s take one step back; rather than demanding that people "help you out", maybe you can explain *why* you don''t want to change your association... -- 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.
hanish jadala
2012-Jun-13 09:20 UTC
Re: how to update a table which is connected with joins
thanks for your reply guys. hi Michael Pavling i can not change my relationship because i have used in many other places if i change relationship i have to make more changes in my app that is y i can not change my relationship. thanks in advance On Wed, Jun 13, 2012 at 1:51 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 13 June 2012 08:31, hanish jadala <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > hi all help me out guys > > > > > > thanks in advance > > > > On Tue, Jun 12, 2012 at 3:07 PM, hanish jadala < > emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> > >> no with our changing the relationship can i update values. > > > We did - you refused to do it :-/ > > Let''s just restate your position: You want to have a habtm join, with > extra information in the join table. This type of join typically does > not have a model, and thus no way of updating those extra fields > (although a "feature" of Rails does/did extend columns in the join > table to both sides of the association). > You don''t want to add a new model and join through it (the way it > would be done normally). > So you see the circular problem you have... > > Let''s take one step back; rather than demanding that people "help you > out", maybe you can explain *why* you don''t want to change your > association... > > -- > 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. > >-- 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
2012-Jun-13 09:26 UTC
Re: how to update a table which is connected with joins
On 13 June 2012 10:20, hanish jadala <emailtohoneyruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi Michael Pavling i can not change my > relationship because i have used in many other places if i change > relationship i have to make more changes in my app that is y i can not > change my relationship.So instead of doing a refactor to support the new functionality you want (a moderately fiddly job to change "many other places" - but an opportunity to DRY them up...), you''re going to plan to bodge in something that will make it practically impossible to ever refactor this area of code in the future. This will make any future functionality changes in this area an absolute nightmare. Google "technical debt". -- 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.