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:in `block 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:in
`assign_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:in `block 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:in
`assign_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:in `block 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:in
`transaction''
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:in
`update_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:in
`call''
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:in
`respond_to''
app/controllers/a_w_requests_controller.rb:106:in `update''
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:in
`send_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:in
`process_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:in
`run_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:in
`process_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:in `block 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:in
`instrument''
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:in
`process_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:in `process''
actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:in `process''
actionpack (3.1.3) lib/action_controller/metal.rb:193:in `dispatch''
actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:in
`dispatch''
actionpack (3.1.3) lib/action_controller/metal.rb:236:in `block 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:in
`dispatch''
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:in `block 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:in
`optimized_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:in `call''
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:in `call''
rack (1.3.5) lib/rack/etag.rb:23:in `call''
rack (1.3.5) lib/rack/conditionalget.rb:35:in `call''
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:in
`call''
actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:in
`call''
rack (1.3.5) lib/rack/session/abstract/id.rb:195:in `context''
rack (1.3.5) lib/rack/session/abstract/id.rb:190:in `call''
actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:in
`call''
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:in
`call''
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:in
`call''
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in
`call''
rack (1.3.5) lib/rack/sendfile.rb:101:in `call''
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:in
`call''
railties (3.1.3) lib/rails/rack/logger.rb:13:in `call''
rack (1.3.5) lib/rack/methodoverride.rb:24:in `call''
rack (1.3.5) lib/rack/runtime.rb:17:in `call''
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in
`call''
rack (1.3.5) lib/rack/lock.rb:15:in `call''
railties (3.1.3) lib/rails/engine.rb:456:in `call''
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"
@a_w_request.updated_by=@remote_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| %>
<label><b>*Requester Contact</b></label>
<%= f.text_field :requester_contact %>
</div>
<div class="field">
<label><b>*Needed By</b></label>
<%= f.date_select :needed_by, :default => 2.days.from_now %>
</div>
<%= render :partial => ''w_a_details/form'',:locals =>
{:form => f} %>
<p><%= f.link_to_add "Add Request", :w_a_details
%></p>
<div class="actions">
<%= f.submit %>
</div>
<% 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 %>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/6yeCUqAyC_sJ.
For more options, visit https://groups.google.com/groups/opt_out.