Since I upgraded to 1.1, I am getting ''ActiveRecord::ReadOnlyRecord'' exceptions when trying to save a specific record. I read up on ActiveRecord::Base.readonly? but I don''t think the condition there (objects pulled in from a certain JOIN type) applies. Here''s my code that is throwing the exception: @company = session[:company] @company.bytes_used = @company.calculate_megabytes_used @company.save session[:company] = @company This was working under 1.0 and I checked SVN and I don''t see any changes to this code in my repository since then... What could be causing this? Any ideas? Thanks, Hunter
I''m having the same troubles. I have a has_and_belongs_to_many relationship which is causing me the same problem. I modify the model from the association and it errors out when I save. This also worked for me pre 1.1. Any ideas on how I can make this work and not be read only? This only seems to be a problem with has_and_belongs_to_many realtionships. (three tables, crawlers, teams, crawlers_teams) crawler model relationship has_and_belongs_to_many :teams for team in crawler.teams team.name = "Mets" team.save end Thanks, Dallas HH wrote:> Since I upgraded to 1.1, I am getting ''ActiveRecord::ReadOnlyRecord'' > exceptions when trying to save a specific record. > > I read up on ActiveRecord::Base.readonly? but I don''t think the > condition > there (objects pulled in from a certain JOIN type) applies. > > Here''s my code that is throwing the exception: > > @company = session[:company] > @company.bytes_used = @company.calculate_megabytes_used > @company.save > session[:company] = @company > > This was working under 1.0 and I checked SVN and I don''t see any changes > to > this code in my repository since then... > > What could be causing this? Any ideas? > > Thanks, > Hunter-- Posted via http://www.ruby-forum.com/.
To answer my own question (and the guy before me). Apparently you can''t use the has_and_belongs_to_many associations if you want to update the model from the association because its made read only based off this changelist. Instead it says to do a find by sql. http://dev.rubyonrails.org/changeset/2594 Dallas wrote:> I''m having the same troubles. I have a has_and_belongs_to_many > relationship which is causing me the same problem. I modify the model > from the association and it errors out when I save. This also worked > for me pre 1.1. Any ideas on how I can make this work and not be read > only? This only seems to be a problem with has_and_belongs_to_many > realtionships. > > (three tables, crawlers, teams, crawlers_teams) > crawler model relationship > has_and_belongs_to_many :teams > > for team in crawler.teams > team.name = "Mets" > team.save > end > > Thanks, > Dallas > > > HH wrote: >> Since I upgraded to 1.1, I am getting ''ActiveRecord::ReadOnlyRecord'' >> exceptions when trying to save a specific record. >> >> I read up on ActiveRecord::Base.readonly? but I don''t think the >> condition >> there (objects pulled in from a certain JOIN type) applies. >> >> Here''s my code that is throwing the exception: >> >> @company = session[:company] >> @company.bytes_used = @company.calculate_megabytes_used >> @company.save >> session[:company] = @company >> >> This was working under 1.0 and I checked SVN and I don''t see any changes >> to >> this code in my repository since then... >> >> What could be causing this? Any ideas? >> >> Thanks, >> Hunter-- Posted via http://www.ruby-forum.com/.
I''ve been using Join Models myself, but wanted to use an "acts_as_list" with a many-to-many relationship. Setting up something like this doesn''t currently work with a Join Model approach. Someone wrote a "acts_as_habtm_list" plugin that works great... but does requires a non-Join Model approach. If anyone has time to whip up a Join Model version of this, that would be great :) On 5/16/06, Dallas <dallas.devries@gmail.com> wrote:> > To answer my own question (and the guy before me). > > Apparently you can''t use the has_and_belongs_to_many associations if you > want to update the model from the association because its made read only > based off this changelist. Instead it says to do a find by sql. > > http://dev.rubyonrails.org/changeset/2594 > > > > Dallas wrote: > > I''m having the same troubles. I have a has_and_belongs_to_many > > relationship which is causing me the same problem. I modify the model > > from the association and it errors out when I save. This also worked > > for me pre 1.1. Any ideas on how I can make this work and not be read > > only? This only seems to be a problem with has_and_belongs_to_many > > realtionships. > > > > (three tables, crawlers, teams, crawlers_teams) > > crawler model relationship > > has_and_belongs_to_many :teams > > > > for team in crawler.teams > > team.name = "Mets" > > team.save > > end > > > > Thanks, > > Dallas > > > > > > HH wrote: > >> Since I upgraded to 1.1, I am getting ''ActiveRecord::ReadOnlyRecord'' > >> exceptions when trying to save a specific record. > >> > >> I read up on ActiveRecord::Base.readonly? but I don''t think the > >> condition > >> there (objects pulled in from a certain JOIN type) applies. > >> > >> Here''s my code that is throwing the exception: > >> > >> @company = session[:company] > >> @company.bytes_used = @company.calculate_megabytes_used > >> @company.save > >> session[:company] = @company > >> > >> This was working under 1.0 and I checked SVN and I don''t see any > changes > >> to > >> this code in my repository since then... > >> > >> What could be causing this? Any ideas? > >> > >> Thanks, > >> Hunter > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060630/9fc20614/attachment.html