I don't know if this is an acceptable practice, but I do the following on 
update... and it works for me

def update

unless params[:id].blank?
unless params[:parent_object].blank?

   @p_o_hold = @parent_object.find(params[id])
   unless @p_o_hold.blank?
    myupdatehash = Hash.new
    /////  Then I select from params[:parent_object] that I need and apply 
some validation or database format requirements 
       myupdatehash = [:field => ...., ]
    if @p_o_hold.update_attributes(myupdatehash[0])    
        @child_object = ChildObject.find(@p_o_hold.id)
         unless  @child_object.blank?
            myupdatehash = [:child_field => @p_o_hold.child_field_value]  
## hash object reuse
                @child_object.update_attributes(myupdatehash[0])

.....

On Wednesday, April 29, 2015 at 4:42:05 AM UTC-4, Jagmeet Singh wrote:
>
> *I am inserting a record in 1st table named as Students and I want to 
> insert a record  in another table with a value coming from a column Refid 
> which is in Students table*
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/30591aec-161b-4a99-8929-9b921cd613a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to