Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto diagram generation #252

Merged
merged 3 commits into from May 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -66,6 +66,11 @@ cluster: false
splines: spline
```

Auto generation
---------------

* Run <tt>rails generate erd:install</tt>
* Run <tt>rails db:migrate</tt>, then the diagram is generated

Learn more
----------
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/erd/templates/auto_generate_diagram.rake
Expand Up @@ -2,5 +2,5 @@
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
# NOTE: to have a dev-mode tool do its thing in production.
if Rails.env.development?
Erd.load_tasks
RailsERD.load_tasks
end
10 changes: 10 additions & 0 deletions lib/rails_erd.rb
Expand Up @@ -56,6 +56,16 @@ def default_options
:cluster, false,
]
end

def loaded_tasks=(val); @loaded_tasks = val; end
def loaded_tasks; return @loaded_tasks; end

def load_tasks
return if(self.loaded_tasks)
self.loaded_tasks = true

Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
end
end

module Inspectable # @private :nodoc:
Expand Down