Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Genarate Active Record Model From Existing Mysql Database


  • Please log in to reply
2 replies to this topic

#1 Anggara Jauhari

Anggara Jauhari

    Passenger

  • Members
  • 1 posts

Posted 27 January 2014 - 12:19 AM

Sorry if this has been covered before, I have searched but can't find a workable solution.
How to generate active record model from existing Mysql database?
Thank You for advice.



#2 maxgenus

maxgenus

    Passenger

  • Members
  • 2 posts

Posted 25 February 2014 - 05:54 AM

 you can then create your models and migrations ...is more suited to existing brownfield databases than ActiveRecord....

 

zombie contact lenses

 

blue contact lenses

#3 danielhanke

danielhanke

    Signalman

  • Members
  • 12 posts
  • LocationCologne, Germany

Posted 02 March 2014 - 05:57 PM

How to generate active record model from existing Mysql database?
Thank You for advice.

Can you be a bit more verbose here?

 

in general, when you have a table named bs, you can just create a model class B < ActiveRecord::Base.

 

since not all tables follow the AR naming guides, you might want to set the table-name, primary-key-name etc in your model as well, to make it work like any AR model.  more information needed however.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users