Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Update table

mysql ror

  • Please log in to reply
2 replies to this topic

#1 gvirmani

gvirmani

    Passenger

  • Members
  • 1 posts

Posted 22 August 2013 - 06:38 AM

Hi,

I am working on an Android application which has MySql as database and used rails for server side code. I have been able to add new records into DB through default methods created in controller. Now I need to update a column value in table based on updates received for another table from my application. Say, I get number of rows to insert in "Orders" table and when I do the insert for this, I have to update another table as Order "received". I understand that I may have to implement this logic in Active record but not sure how to do this. I researched a lot and read quite a few rails tutorials but unable to find solution which will work. Basically I am confused how to link Model and controller class. Till now I have passed url in my application which comes directly to controller and DB is updated. But now I have to extract some values from the json received and then update another table.

 

Also when I receive my the order, I have to push this order to another client. So not sure how to push this.

 

I am totally a beginner in rails so not sure how to implement this. Sincere apologies if it sound a basic question for this forum but after a thorough research I couldn't get a solution. Would be great if someone can provide relevant pointers. Thanks.



#2 dowdrake

dowdrake

    Passenger

  • Members
  • 2 posts

Posted 23 August 2013 - 04:12 PM

Now I need to update a column value in table based on updates received for another table from my application. Say, I get number of rows to insert in "Orders" table and when I do the insert for this, I have to update another table as Order "received".

 

Could you post your code for the Order model and the other related models along with your Orders controller code?  Also, it would be helpful to know what version of Rails you are using. 

 

 

Also when I receive my the order, I have to push this order to another client. So not sure how to push this.

When you say 'client', are you referring to an object of a Client model?  -- or do you mean that you want to have the controller generate a new request to a different server?


  • james likes this

#3 Vito Botta

Vito Botta

    Signalman

  • Members
  • 12 posts
  • LocationEspoo, Finland

Posted 15 September 2013 - 08:39 PM

I am not sure if I understood correctly - as dowdrake said some code would be helpful - but have you looked into Callbacks/Observers? (regarding updating a table when inserts happen in another table)







Also tagged with one or more of these keywords: mysql, ror

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users