readonly - ActiveRecord::ReadOnlyRecord (ActiveRecord::ReadOnlyRecord): during update -
i think i'm still newbie, need again. while i'm working habtm association have problem. have form enter information computer. association habtm between machine , operatingsystem.
class machine < activerecord::base .... has_and_belongs_to_many :operatingsystems, :join_table => "machines_operatingsystems", :readonly => false .... end class operatingsystem < activerecord::base .... has_and_belongs_to_many :machines, :join_table => "machines_operatingsystems", :readonly => false .... end
i display operating systems check box.
i modified update of machines controller
def update params[:machine][:operatingsystem_ids] ||= [] @machine = machine.find(params[:id], :readonly => false) respond_to |format| if @machine.update_attributes(params[:machine]) flash[:notice] = 'machine updated.' format.html { redirect_to(@machine) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @machine.errors, :status => :unprocessable_entity } end end end
but if edit machine without example change name , click on update have following error:
activerecord::readonlyrecord (activerecord::readonlyrecord): app/controllers/machines_controller.rb:72 app/controllers/machines_controller.rb:71:in `update' passenger (2.2.15) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request' passenger (2.2.15) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop' passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler' passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application' passenger (2.2.15) lib/phusion_passenger/utils.rb:252:in `safe_fork' passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:163:in `start' passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:222:in `start' passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application' passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add' passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application' passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize' passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application' passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application' passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop' passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
thanks in advance help.
does machines_operatingsystems
table have columns on other machine_id
, operatingsystem_id
? if does, activerecord marking record returned association readonly.
one culprit timestamp columns on join table. if migration creates machines_operatingsystems
includes call timestamps
, may source of problem.
Comments
Post a Comment