# Rails Save/Update not working - Oracle

**URL:** <https://www.ruby-forum.com/t/rails-save-update-not-working-oracle/128452>\
**Category:** Rails\
**Created:** [February 7, 2008, 8:24pm UTC](https://www.ruby-forum.com/t/rails-save-update-not-working-oracle/128452 "2008-02-07T20:24:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![miken700](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@miken700](https://www.ruby-forum.com/u/miken700)\
**Post date:** [February 7, 2008, 8:24pm UTC](https://www.ruby-forum.com/t/rails-save-update-not-working-oracle/128452/1 "2008-02-07T20:24:07Z")

</div>

I have a legacy schema (that I cannot change) that I am working with,  
building a quick maintenance front end using Rails. The problem is  
that when I process the Update nothing happens on the Oracle system.  
All the trace logs indicate the right SQL is being generated and  
called, but nada happens in Oracle. I am trying to start simple and  
update a single column: network\_id. If you look at the logging data  
you can see the SQL update seems proper, with the old value and new  
value

OLD - network\_id = ‘sarB555’  
NEW - network\_id = ‘sarB333’

Running on Window, Ruby 1.8.6, Rails 1.2.6, Oracle 10G

Any suggestions would be appreciated. Thanks.  
Mike

Here is some code:

=== # MODEL - The object I’m trying to update  
class ClientDetail \< ActiveRecord::Base

```
cattr_reader :per_page
@@per_page = 20

set_table_name "CLIENT_DETAILS"
set_primary_key "CLIENT_DETAILS_ID"

# Relationships
has_many :client_state, :class_name => 'ClientState', :foreign_key

```

=\> “CLIENT\_DETAILS\_ID”

```
# Reference Data values to get descriptions
belongs_to :user_type, :foreign_key => "USER_TYP_ID"
belongs_to :presence_type, :foreign_key =>

```

“PRESENCE\_TYP\_ID”  
belongs\_to :presence\_device\_type, :foreign\_key =\>  
“PRESENCE\_DEVICE\_TYP\_ID”  
belongs\_to :provider, :foreign\_key =\> “PROVIDER\_ID”  
end

=== # CONTROLLER methods  
#Load the rhtml page  
def edit\_client\_details  
@page\_title = 'Update Client Detail ’  
@current\_client\_detail = ClientDetail.find(params[:id])  
end

# Save the updated network\_id

def save\_client\_detail\_changes  
@current\_client\_detail = ClientDetail.find(params[:id])  
newNetworkId = params[:current\_client\_detail][:network\_id]  
if  
@current\_client\_detail.update\_attributes(params[:network\_id])  
@current\_client\_detail.update\_attribute(:network\_id,  
newNetworkId)

```
      #Ive tried using this, does not work.
      #@current_client_detail.network_id=newNetworkId

      begin
          @current_client_detail.save!
      rescue
          puts '-- EEEEEEEEEEEEEEE Exception of some kind.'
      end
      flash[:notice] = 'Client Details was successfully updated.'
      redirect_to :action => 'search_for_puids'
    else
      render :action => 'edit_client_details'
    end
    #redirect_to :action => 'search_for_puids'
end

```

=== # LOGGING OUTPUT  
-------------- START #save\_client\_detail\_changes - param[:id] : 121  
============ #save\_client\_detail\_changes - @current\_client\_detail:  
#  
============ #save\_client\_detail\_changes - params[:network\_id] -  
============ #save\_client\_detail\_changes -  
params[:current\_client\_detail][:netwo  
rk\_id] - sarB333  
update\_attributes for network Id happening  
------------ Old Value: sarB555  
------------ New Value: sarB333  
127.0.0.1 - - [07/Feb/2008:12:02:53 Mountain Standard Time] "POST /  
client\_detail

Processing ClientDetailsNgsController#save\_client\_detail\_changes (for  
127.0.0.1 at 2008-02-07 12:02:53) [POST]  
Session ID: 18cf528d3d578158af255b0df5037b49  
Parameters: {“commit”=\>“Edit”,  
“action”=\>“save\_client\_detail\_changes”, “id”=\>“121”,  
“controller”=\>“client\_details\_ngs”,  
“current\_client\_detail”=\>{“network\_id”=\>“sarB333”}}  
[4;35;1mClientDetail Columns (0.000000) [0m [0m select  
column\_name as name, data\_type as sql\_type, data\_default, nullable,  
decode(data\_type, ‘NUMBER’, data\_precision,  
‘FLOAT’, data\_precision,  
‘VARCHAR2’, data\_length,  
‘CHAR’, data\_length,  
null) as limit,  
decode(data\_type, ‘NUMBER’, data\_scale, null) as scale  
from all\_tab\_columns  
where owner = ‘SOMEUSER’  
and table\_name = ‘CLIENT\_DETAILS’  
order by column\_id  
[0m  
[4;36;1mClientDetail Load (0.015000) [0m [0;1mSELECT \* FROM  
CLIENT\_DETAILS WHERE (CLIENT\_DETAILS.“CLIENT\_DETAILS\_ID” = ‘121’) [0m  
[4;35;1mClientDetail Update (0.016000) [0m [0mUPDATE  
CLIENT\_DETAILS SET presence\_typ\_id = 1.0, network\_id = ‘sarB555’,  
client\_details\_id = 121, provider\_id = 16.0, alt\_user\_typ\_id = 1.0,  
public\_user\_id = ‘3031111111’, pres\_device\_id = ‘a283423334335’,  
pres\_device\_address = NULL, reg\_step\_typ\_id = NULL, user\_typ\_id = 3.0,  
presence\_contxt = NULL, auth\_id = NULL, alt\_public\_user\_id =  
‘3032222222’, presence\_device\_typ\_id = 3.0, auth\_scheme = NULL WHERE  
“CLIENT\_DETAILS\_ID” = NULL [0m  
[4;36;1mClientDetail Update (0.016000) [0m [0;1mUPDATE  
CLIENT\_DETAILS SET presence\_typ\_id = 1.0, network\_id = ‘sarB333’,  
client\_details\_id = 121, provider\_id = 16.0, alt\_user\_typ\_id = 1.0,  
public\_user\_id = ‘3031111111’, pres\_device\_id = ‘a283423334335’,  
pres\_device\_address = NULL, reg\_step\_typ\_id = NULL, user\_typ\_id = 3.0,  
presence\_contxt = NULL, auth\_id = NULL, alt\_public\_user\_id =  
‘3032222222’, presence\_device\_typ\_id = 3.0, auth\_scheme = NULL WHERE  
“CLIENT\_DETAILS\_ID” = NULL [0m  
[4;35;1mClientDetail Update (0.000000) [0m [0mUPDATE  
CLIENT\_DETAILS SET presence\_typ\_id = 1.0, network\_id = ‘sarB333’,  
client\_details\_id = 121, provider\_id = 16.0, alt\_user\_typ\_id = 1.0,  
public\_user\_id = ‘3031111111’, pres\_device\_id = ‘a283423334335’,  
pres\_device\_address = NULL, reg\_step\_typ\_id = NULL, user\_typ\_id = 3.0,  
presence\_contxt = NULL, auth\_id = NULL, alt\_public\_user\_id =  
‘3032222222’, presence\_device\_typ\_id = 3.0, auth\_scheme = NULL WHERE  
“CLIENT\_DETAILS\_ID” = NULL [0m  
Redirected to [http://localhost:3000/client\_details\_ngs/search\_for\_puids](http://localhost:3000/client_details_ngs/search_for_puids)  
Completed in 0.17200 (5 reqs/sec) | DB: 0.04700 (27%) | 302 Found  
[[http://localhost/client\_details\_ngs/save\_client\_detail\_changes/121](http://localhost/client_details_ngs/save_client_detail_changes/121)]
