Nested attributes doesnt get updated

Hi
Am building a nested form and my code works fine with sqlite3 but throws
errors when using Oracle during update action.

Am getting the following error:

ActiveRecord::RecordNotFound in AWRequestsController#update

Couldn’t find WADetail with ID=5000000015 for AWRequest with
ID=5000000022.0

Request

Parameters:

{“utf8”=>“✓”,
“_method”=>“put”,
“authenticity_token”=>“F8KcH1MeagUtyPw7N5IH4cmrY1duE5zXQ/cZJDRqkQc=”,
“a_w_request”=>{“requester_contact”=>“chitra”,
“needed_by(1i)”=>“2013”,
“needed_by(2i)”=>“2”,
“needed_by(3i)”=>“12”,
“w_a_details_attributes”=>{“0”=>{
“description”=>“d”,
“_destroy”=>“false”,
“id”=>“5000000015”}}},
“commit”=>“Update A w request”,
“id”=>“5000000022”}

*Stack trace:
*activerecord (3.1.3) lib/active_record/nested_attributes.rb:461:in
raise_nested_attributes_record_not_found' activerecord (3.1.3) lib/active_record/nested_attributes.rb:426:inblock in assign_nested_attributes_for_collection_association’
activerecord (3.1.3) lib/active_record/nested_attributes.rb:399:in
each' activerecord (3.1.3) lib/active_record/nested_attributes.rb:399:inassign_nested_attributes_for_collection_association’
activerecord (3.1.3) lib/active_record/nested_attributes.rb:287:in
w_a_details_attributes=' activerecord (3.1.3) lib/active_record/base.rb:1751:inblock in
assign_attributes’
activerecord (3.1.3) lib/active_record/base.rb:1747:in each' activerecord (3.1.3) lib/active_record/base.rb:1747:inassign_attributes’
activerecord (3.1.3) lib/active_record/persistence.rb:162:in block in update_attributes' activerecord (3.1.3) lib/active_record/transactions.rb:295:inblock in
with_transaction_returning_status’
activerecord (3.1.3)
lib/active_record/connection_adapters/abstract/database_statements.rb:192:in
transaction' activerecord (3.1.3) lib/active_record/transactions.rb:208:intransaction’
activerecord (3.1.3) lib/active_record/transactions.rb:293:in
with_transaction_returning_status' activerecord (3.1.3) lib/active_record/persistence.rb:161:inupdate_attributes’
app/controllers/a_w_requests_controller.rb:107:in block in update' actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:269:incall’
actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:269:in
retrieve_response_from_mimes' actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:194:inrespond_to’
app/controllers/a_w_requests_controller.rb:106:in update' actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:insend_action’
actionpack (3.1.3) lib/abstract_controller/base.rb:167:in
process_action' actionpack (3.1.3) lib/action_controller/metal/rendering.rb:10:inprocess_action’
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (3.1.3) lib/active_support/callbacks.rb:425:in_run__486895298054507173__process_action__168722878175211407__callbacks’
activesupport (3.1.3) lib/active_support/callbacks.rb:386:in
_run_process_action_callbacks' activesupport (3.1.3) lib/active_support/callbacks.rb:81:inrun_callbacks’
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:17:in
process_action' actionpack (3.1.3) lib/action_controller/metal/rescue.rb:17:inprocess_action’
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:30:in
block in process_action' activesupport (3.1.3) lib/active_support/notifications.rb:53:inblock
in instrument’
activesupport (3.1.3)
lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (3.1.3) lib/active_support/notifications.rb:53:ininstrument’
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:29:in
process_action' actionpack (3.1.3) lib/action_controller/metal/params_wrapper.rb:201:inprocess_action’
activerecord (3.1.3)
lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (3.1.3) lib/abstract_controller/base.rb:121:inprocess’
actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:in process' actionpack (3.1.3) lib/action_controller/metal.rb:193:indispatch’
actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:in
dispatch' actionpack (3.1.3) lib/action_controller/metal.rb:236:inblock in
action’
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in call' actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:indispatch’
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:29:in call' rack-mount (0.8.2) lib/rack/mount/route_set.rb:152:inblock in call’
rack-mount (0.8.2) lib/rack/mount/code_generation.rb:96:in block in recognize' rack-mount (0.8.2) lib/rack/mount/code_generation.rb:103:inoptimized_each’
rack-mount (0.8.2) lib/rack/mount/code_generation.rb:95:in recognize' rack-mount (0.8.2) lib/rack/mount/route_set.rb:141:incall’
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:in
call' actionpack (3.1.3) lib/action_dispatch/middleware/best_standards_support.rb:17:incall’
rack (1.3.5) lib/rack/etag.rb:23:in call' rack (1.3.5) lib/rack/conditionalget.rb:35:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/head.rb:14:in call' actionpack (3.1.3) lib/action_dispatch/middleware/params_parser.rb:21:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:in call' rack (1.3.5) lib/rack/session/abstract/id.rb:195:incontext’
rack (1.3.5) lib/rack/session/abstract/id.rb:190:in call' actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:incall’
activerecord (3.1.3) lib/active_record/query_cache.rb:64:in call' activerecord (3.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:in
block in call' activesupport (3.1.3) lib/active_support/callbacks.rb:392:in_run_call_callbacks’
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in
run_callbacks' actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in
call' rack (1.3.5) lib/rack/sendfile.rb:101:incall’
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in
call' actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:incall’
railties (3.1.3) lib/rails/rack/logger.rb:13:in call' rack (1.3.5) lib/rack/methodoverride.rb:24:incall’
rack (1.3.5) lib/rack/runtime.rb:17:in call' activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:incall’
rack (1.3.5) lib/rack/lock.rb:15:in call' railties (3.1.3) lib/rails/engine.rb:456:incall’
railties (3.1.3) lib/rails/railtie/configurable.rb:30:in
`method_missing’

This is my update function:
def update
@a_w_request = AWRequest.find(params[:id])
@a_w_request.status = “Active”
@[email protected]_user
respond_to do |format|
if @a_w_request.update_attributes(params[:a_w_request])
format.html { redirect_to @a_w_request, notice: ‘Request was
successfully updated.’ }
format.json { head :no_content }
else
format.html { render action: “edit” }
format.json { render json: @a_w_request.errors, status:
:unprocessable_entity }
end
end
end

Models:
a_w_request.rb
class AWRequest < ActiveRecord::Base
set_primary_key :request_id
set_sequence_name “w_request_details_seq”
set_table_name “w_request_details”

attr_accessible :requester_contact, :needed_by,
:w_a_details_attributes
has_many :w_a_details, :dependent => :destroy
accepts_nested_attributes_for :w_a_details, :allow_destroy => :true,
:reject_if => proc{ |attrs| attrs.all? {|k,v| v.blank? } }

def to_param
request_id.to_i.to_s
end
end

w_a_detail.rb:
class WADetail < ActiveRecord::Base
set_primary_key :w_a_detail_id
set_sequence_name “w_a_details_seq”
set_table_name “w_a_details”
attr_accessible :description
belongs_to :a_w_request
def to_param
w_a_detail_id.to_i.to_s
end
end

Forms:
*a_w_requests/_form.html.erb:
*<%= nested_form_for(@a_w_request) do |f| %>

*Requester Contact
<%= f.text_field :requester_contact %>

*Needed By <%= f.date_select :needed_by, :default => 2.days.from_now %>

<%= render :partial => ‘w_a_details/form’,:locals => {:form => f} %>

<%= f.link_to_add "Add Request", :w_a_details %>

<%= f.submit %>
<% end %>

*w_a_details/_form.html.erb

*<%= form.fields_for :w_a_details do |a_form| %>

<%=a_form.text_field :description %>

<%=a_form.link_to_remove "Remove" %>

<% end %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs