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
Create a dashbard generator #20
Conversation
@@ -0,0 +1,17 @@ | |||
class DashboardGenerator < Rails::Generators::NamedBase | |||
source_root File.expand_path('../templates', __FILE__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
:lifetime_value, | ||
:created_at, | ||
:updated_at, | ||
] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify why this file was updated within the context of this commit? Wondering if it is related/within the context of the commit's purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not super related. I updated the structure a little to reflect the generated dashboard.
Any thoughts on how to test this? |
private | ||
|
||
def attributes | ||
klass.column_names + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attribute_names
This looks correct to me from a generator standpoint. Is the reflection stuff public API? Ammeter can help you test the file creation aspect of this, verify the generated file is valid ruby, etc. Faking a model out and all of that reflection seems like it would be hard. I'd probably try to have a real model available for the test. |
It's probably the most ambiguous part of Active Record as to whether it's public or not. Generally speaking, no. |
:belongs_to | ||
else | ||
throw "Unknown association type: #{reflection.inspect}\n" + | ||
"Please open an issue on the Administrate repo." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use 2 (not 0) spaces for indenting an expression spanning multiple lines.
Related deprecation issues on ActiveAdmin: activeadmin/activeadmin#3930 |
The generator pulls column names and types from the database, using the methods `.type_for_attribute` and `.reflections`. - Fill in missing mappings to `BaseDashboard#field_registry`. References: http://edgeguides.rubyonrails.org/generators.html https://github.com/ryanb/nifty-generators https://trello.com/c/My9ldlzZ
Alright, I'm willing to merge this for a few reasons:
@sgrif I'm really interested in playing with the Attributes API, and making sure this is forwards-compatible before we launch 1.0. Thanks for the advice with this! I'm sure we'll have some more conversations along similar lines before too long 😄 |
As of Ruby 3.0 webrick is no longer part of the Ruby standard library: https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
Bump actionpack from 6.1.3.2 to 6.1.4.1
The generator pulls column names and types from the database,
using the methods
#column_names
andcolumn_types
.BaseDashboard#field_registry
.References:
http://edgeguides.rubyonrails.org/generators.html
https://github.com/ryanb/nifty-generators
When the user runs
rails generate dashboard order
,they get a file
app/dashboards/order_dashboard.rb
with the contents:https://trello.com/c/My9ldlzZ