Search code examples
ruby-on-railsactivemodelrails-generate

How to use rails generators without active record


I am building a rails app without a database. In Disable ActiveRecord for Rails 4 I learned how to configure the app so that the absence of the database related gems does not interfere with running it. The problem is that I still want to create models using the commend rails generate mode MyModel. Under this configuration, the above command does nothing at all. I am assuming here I would need to require some modules (for example, activemodel, which seems to provide ActiveRecord-like capabilities without necessarily having a DB) in application.rb, but I can seem to find which. Could someone help?

Thanks in advance


Solution

  • You can take a look at How to create custom generators for my rails app.
    Basically you will have to change the behavior of your model generators. This way you can tell which file will be created, with which code template and etc.