hema gonaboina
2009-Feb-04 10:32 UTC
update_attributes not working on production environment
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Feb-04 11:09 UTC
Re: update_attributes not working on production environment
On 4 Feb 2009, at 10:32, hema gonaboina wrote:> 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) > > > > 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. >Does your ActiveRecord model have method/associations called transaction or changed ? (PS it''s CRUD not CURD) Fred> >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Feb-04 11:21 UTC
Re: update_attributes not working on production environment
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hema Gonaboina
2009-Feb-04 12:32 UTC
Re: update_attributes not working on production environment
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2009-Feb-04 12:50 UTC
Re: update_attributes not working on production environment
On Wed, Feb 4, 2009 at 4:32 AM, Hema Gonaboina < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Feb-04 13:38 UTC
Re: update_attributes not working on production environment
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-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > 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. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Feb 4, 6:38 pm, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote:> 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-l...@andreas-s.net > wrote: > > > 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.soli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > 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. > > -- > > Posted viahttp://www.ruby-forum.com/. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Feb 5, 11:31 am, Hema <hema.soli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > On Feb 4, 6:38 pm, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > > 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-l...@andreas-s.net > wrote: > > > > 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.soli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > 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. > > > -- > > > Posted viahttp://www.ruby-forum.com/. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---