-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handling the unneeded migration filecreation using method_added captu…
…re approach Signed-off-by: Naveen Honest Raj K <naveendurai19@gmail.com>
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
require 'active_admin/mongoid' | ||
require "rails/generators/actions" | ||
require "rails/generators/named_base" | ||
|
||
# Considering the Rails::Generators::NamedBase is one of the nearest ancestor to | ||
# ActiveAdmin::Generators::InstallGenerator, we can open the class and an empty create_migration | ||
# to the class(which will overridden by other subclasses). We can specifically focus on the | ||
# ActiveAdmin::Generators::InstallGenerator class and apply remove_method during the method_added call | ||
# and thereby pushing ActiveAdmin::Generators::InstallGenerator to use our empty create_migrations method. | ||
|
||
Rails::Generators::NamedBase.class_eval do | ||
|
||
def create_migrations | ||
end | ||
|
||
def self.inherited(klass) | ||
super | ||
if klass.name == "ActiveAdmin::Generators::InstallGenerator" | ||
|
||
klass.class_eval do | ||
def self.method_added(method_name) | ||
super | ||
remove_method method_name if method_name == :create_migrations | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|