How to create active record models from a database

I am looking for a tool or method that can convert my huge old database into active definitions of record models ... for example, reverse engineering ...

+3
source share
5 answers

This is less of a reverse engineering problem, and more important is the problem of “is your legacy database related to active write agreements”. Most of them do not, and in my experience, it is almost easier to do some migration work at the end of the data in order to get it in such a state that it complies with these conventions. Rails is a very stubborn piece of software, the less you argue with it, the happier you will be.

My two cents ...

+6

, . , . , :

class Artikelgruppe < ActiveRecord::Base
  set_table_name "tblArtGrp"
  set_primary_key "ArtGrpID"
end

Rails , , . , , 7 Rails, 7 .

Rails , ? , , - . , , Rails ...

+1

ActiveRecord . . users, app/models/user.rb

class User < ActiveRecord::Base

end

​​ , .

, , , . Rails, , , , - Rail Conposition over configuration. , Rails .

0

RMRE gem. , RMRE.

0

RMRE . rare_map.yml, , . . /config, , , .

: rails [module] _base.rb, ActiveRecord:: Base, ActiveRecord:: Base .

In RMRE models, all relationships (affiliation, has_many, etc.) are generated that are filled in automatically for you. It will be used for non-rail applications, or if you specify models in your configuration files as a module for you.

rare_map gem mentioned above only created empty models for me that don't buy you much.

0
source

Source: https://habr.com/ru/post/1795149/


All Articles