Skip to content

Respect pluralize_table_names option when creating views#459

Open
flanger001 wants to merge 1 commit intoscenic-views:mainfrom
flanger001:main
Open

Respect pluralize_table_names option when creating views#459
flanger001 wants to merge 1 commit intoscenic-views:mainfrom
flanger001:main

Conversation

@flanger001
Copy link
Copy Markdown

References #312

As a preamble, I have followed all the steps in CONTRIBUTING.md and have attempted to change the smallest number of lines of code possible.

This PR allows Scenic to respect the pluralize_table_names option when creating views. Formerly, if pluralize_table_names was set to false, Scenic would still create a pluralized view and migration file, e.g.:

# config/application.rb

Rails.application.configure do
  # snip
  config.active_record.pluralize_table_names = false
end

The generator command:

./bin/rails g scenic:view search

Outputs:

  • db/migrate/TIMESTAMP_create_searches.rb
  • db/views/searches_v01.sql.

Now, with the aforementioned config, this is our output:

  • db/migrate/TIMESTAMP_create_search.rb
  • db/views/search_v01.sql.

Updating migrations works as well: ./bin/rails generate scenic:view search a second time will output:

  • db/migrate/TIMESTAMP_update_search_to_version_2.rb
  • db/views/search_v02.sql.

@flanger001
Copy link
Copy Markdown
Author

@derekprior What do you think of this approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant