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.
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”
thanks for your reply guys. hi Michael P. 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.
hi Michael P. 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.
On Tue, Jun 12, 2012 at 3:07 PM, hanish jadala [email protected]
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…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.