-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let users undo the
administrate:views
generator
Fixes #310 Problem: Rails provides a way to undo the effects of generators, by running the command `rails destroy GENERATOR_NAME`. With the way that we had set up our hierarchy of generators, Rails did not know how to undo the effects of sub-generators. For example, with the `administrate:views` generator, we were calling `Rails::Generators.invoke("administrate:views:index")`. Whether the generator was run with the `generate` or `destroy` command did not make a difference - the index generator would always be invoked as if it were run with `generate`. Solution: Rails generators use the `@behavior` instance variable to keep track of how the generator was run. This variable can be either `:invoke` or `:revoke`. Pass this variable as an option to the sub-generators to ensure they have the same behavior as the parent. Minor changes: Extract `Administrate::GeneratorHelpers` to store common generator-related methods.
- Loading branch information
Showing
9 changed files
with
48 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Administrate | ||
module GeneratorHelpers | ||
def call_generator(generator, *args) | ||
Rails::Generators.invoke(generator, args, generator_options) | ||
end | ||
|
||
private | ||
|
||
def generator_options | ||
{ behavior: behavior } | ||
end | ||
end | ||
end |
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
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
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
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
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
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
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
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