Forum: Ruby on Rails update_attributes not working on production environment

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C6b3fb1b16a9878bc793a90bdc1c9799?d=identicon&s=25 Hema Gonaboina (hema_mca)
on 2009-02-04 11:33
(Received via mailing list)
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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-04 12:13
(Received via mailing list)
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
3131fcea0a711e5ad89c8d49cc9253b4?d=identicon&s=25 Julian Leviston (Guest)
on 2009-02-04 12:24
(Received via mailing list)
What orm are you using?

Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/

On 04/02/2009, at 9:32 PM, hema gonaboina <hema.solivar@gmail.com>
C6b3fb1b16a9878bc793a90bdc1c9799?d=identicon&s=25 Hema Gonaboina (hema_mca)
on 2009-02-04 13:32
Julian Leviston wrote:
> What orm are you using?
>
> Blog: http://random8.zenunit.com/
> Learn rails: http://sensei.zenunit.com/
>
> On 04/02/2009, at 9:32 PM, hema gonaboina <hema.solivar@gmail.com>


 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.
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2009-02-04 13:50
(Received via mailing list)
On Wed, Feb 4, 2009 at 4:32 AM, Hema Gonaboina <
rails-mailing-list@andreas-s.net> 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
3131fcea0a711e5ad89c8d49cc9253b4?d=identicon&s=25 Julian Leviston (Guest)
on 2009-02-04 14:38
(Received via mailing list)
Your model didn't appear to inherit from active record base.

Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/

On 04/02/2009, at 11:32 PM, Hema Gonaboina
<rails-mailing-list@andreas-s.net
C6b3fb1b16a9878bc793a90bdc1c9799?d=identicon&s=25 Hema Gonaboina (hema_mca)
on 2009-02-05 07:31
(Received via mailing list)
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
C6b3fb1b16a9878bc793a90bdc1c9799?d=identicon&s=25 Hema Gonaboina (hema_mca)
on 2009-02-06 15:57
(Received via mailing list)
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
This topic is locked and can not be replied to.