# Update\_attributes not working on production environment

**URL:** <https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413>\
**Category:** Rails\
**Created:** [February 4, 2009, 11:33am UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413 "2009-02-04T11:33:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 4, 2009, 11:33am UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/1 "2009-02-04T11:33:42Z")

</div>

Hi,

```
 Here is my Sample Code... I am calling the genericCURDoperation 

```

action  
through the view and sending the xml containing the record to be  
inserted/updated along with its key value(the primary key field and it’s  
value in the xml)

The controller action is

def genericCURDoperation  
companyid = session[:companyid]  
obj = MGenericCurdOperation.new(params[:objects],companyid)  
result = obj.genericAction  
puts result  
end

In my MGenericCurdOperation model

class MGenericCurdOperation  
attr\_accessor :companyid,:objects

def intialize(xml,companyid)  
@objects = xml  
@companyid = companyid  
end

```
       def genericAction
                  hash = @objects.to_hash
                  operation = hash['operation']

       if operation == "insert" then
             status = saveToDB(hash['record'],companyid)
                  elsif operation == "update" then
              status = UpdateToDB(hash['record'],companyid)
               .................
                 end
                 return status
        end

        def saveToDB(record,companyid)
                      ............
        end

        def UpdateToDB(record,companyid)
 hash = record.to_hash
     key = hash['key']

if key==nil then
       puts " the key not coming thourgh xml"
                          return nil
   end

value = hash[key.to_s]
model = hash['model']
record = model.find(:all,:conditions=>["#{key}=?",value]) #retriving 

```

the  
record from db  
updateRecord = model.new(hash[‘record’]) # record with updated  
fileds  
,consits every filed in the record except the key value,attribute  
updateRecord.TimeUpdate = DateTime.now # Here whatever the other  
requirements and conversions added to the updateRecord and also  
checking  
the required fields to be non empty etc;  
recordHash = Hash.from\_xml(updateRecord.to\_xml)  
root = recordHash.keys  
rootElement = root(0)  
if record.update\_attributes(recordHash[rootElement.to\_s]) then  
puts record.to\_xml  
puts “saved successfully”  
redirect\_to ‘index’  
end  
end  
end

this is my code with some more operations also.When I debug the control  
going to the update\_attributes but it is not updating in database.even  
the  
record.to\_xml showing the contents as updated but in can’t be viewed in  
database and also on index page. Can anyone please help me due to this  
my  
application not working and can’t be moved to the production.

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 4, 2009, 12:13pm UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/2 "2009-02-04T12:13:06Z")

</div>

On 4 Feb 2009, at 10:32, hema gonaboina wrote:

> control going to the update\_attributes but it is not updating in  
> database.even the record.to\_xml showing the contents as updated but  
> in can’t be viewed in database and also on index page. Can anyone  
> please help me due to this my application not working and can’t be  
> moved to the production.

Does your ActiveRecord model have method/associations called  
transaction or changed ? (PS it’s CRUD not CURD)

Fred

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 4, 2009, 12:24pm UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/3 "2009-02-04T12:24:16Z")

</div>

What orm are you using?

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

On 04/02/2009, at 9:32 PM, hema gonaboina [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 4, 2009, 1:32pm UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/4 "2009-02-04T13:32:06Z")

</div>

Julian L. wrote:

> What orm are you using?
> 
> Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
> Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)
> 
> On 04/02/2009, at 9:32 PM, hema gonaboina [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Hi,  
In my active record I am not having any associations with the name  
trasaction or changed.  
But,In my environment.rb I specified my rails version as 2.1.0 but  
it is using the activerecord-2.2.2.I am using netbeans IDE for  
development,and I am using mysql for the database and ActiveRecord::Base  
for the connections.

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 4, 2009, 1:50pm UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/5 "2009-02-04T13:50:49Z")

</div>

On Wed, Feb 4, 2009 at 4:32 AM, Hema G. \<  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:

> Hi,  
> In my active record I am not having any associations with the name  
> trasaction or changed.  
> But,In my environment.rb I specified my rails version as 2.1.0 but  
> it is using the activerecord-2.2.2.I am using netbeans IDE for  
> development,and I am using mysql for the database and ActiveRecord::Base  
> for the connections.

Hi, do you have a version of rails in the vendor directory of your Rails  
application?

-Conrad

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 4, 2009, 2:38pm UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/6 "2009-02-04T14:38:57Z")

</div>

Your model didn’t appear to inherit from active record base.

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

On 04/02/2009, at 11:32 PM, Hema G.  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 5, 2009, 7:31am UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/7 "2009-02-05T07:31:57Z")

</div>

Hi,

Where I have to check in vendor directory

I have the plugins directory only containing

1. validates\_date\_and\_time
2. restful\_authentication
3. rubyamf

---

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [February 6, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/update-attributes-not-working-on-production-environment/159413/8 "2009-02-06T15:57:28Z")

</div>

I uninstalled rails 2.2.2 in my associations folder of activerecord  
2.1.0 there is no method like transfer/change any one please help me…  
I am unable to proceed furthur
