-
Notifications
You must be signed in to change notification settings - Fork 87
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
Model to schema naming conventions #76
Comments
I agree, we should change this. We should also look at adding a pluralize helper since adding an |
Regarding the snake case table names - I think that fix is easy: # Currently
{% name_space = @type.name.gsub(/::/, "_").downcase.id %}
# Change to
{% name_space = @type.name.gsub(/::/, "_").underscore.id %} Regarding dealing with pluralization, I think leveraging an existing library is a good idea: https://github.com/mosop/string_inflection |
I’d second pulling in a proper inflector. There are undoubtedly times where pedantic inflection is mote confusing to the majority of people (eg Media, Data), but more often than not I appreciated the ease of Rails inflection. In other projects I’ve attempted to live with a cheaper solution and regretted it. |
There is a nice inflector created here https://github.com/luckyframework/lucky_inflector |
@eliasjpr As it stands with Granite, a fair amount of inflection assumptions are made in macros. I think relationships will need a major rewrite out of macro land before any real inflection library can be used. In the interim, I think fully configurable associations such as #103 is a workable solution. |
|
Opening a new ticket #129 regarding the inflector |
Coming from ActiveRecord, the Model name to table name convention is great to see. I did notice that there is one difference, and I wanted to bring it up as it was the only difference I saw between Granite's and ActiveRecord's. It can be seen in this error:
The Rails Guides outline this convention for ActiveRecord:
In this case, you'd expect the schema relation to be called
song_threads
.Here's my SongThread class for completeness to the example:
The text was updated successfully, but these errors were encountered: