Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apartment gem migrations inside Rails Engine

I'm building a Rails Engine inside another rails app. The engine's rake tasks seem to get scoped to app:

# inside <app_root>/engines/engine_name
$ rake -T apartment
rake app:apartment:migrate       # Migrate all tenants

Whereas from the app's root:

#inside <app_root>/
$ rake -T apartment
rake apartment:migrate       # Migrate all tenants

My problem is when I run

# inside <app_root>/engines/engine_name
RAILS_ENV=test rake db:migrate

I get the following error:

rake aborted! Don't know how to build task 'apartment:migrate'

Seems like it should be calling the app:apartment:migrate task, but I'm not sure how to do this so I can test this engine on its own with RSpec

like image 775
typeoneerror Avatar asked Dec 05 '25 15:12

typeoneerror


1 Answers

You should have a Rakefile for the engine here: <app_root>/engines/engine_name/Rakefile

Try adding this line to the bottom of it to load the rake tasks from the apartment gem:

load 'tasks/apartment.rake'
like image 196
Arctodus Avatar answered Dec 07 '25 04:12

Arctodus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!