Currently the gem is not a set and forget tool, you still need to do a lot of manual renaming afterward the gem has done its work.
I would like this gem to rename much more comprehensively than it currently is, and as such will work towards completing these following steps, some of which have already been completed:
- Create a comprehensive fake rails app. - Yes
- Check if there's already a model with the same name as what you're going to (file exists?) -> Yes
- Commit what we have in git - Yes
- Change model file name (campaign.rb -> distribution.rb) - Yes
- Update model folder (if necessary) (models/campaigns/.rb -> models/distributions/.rb) - Yes
- Update class reference (class Campaign -> class Distribution) - Yes
- Update has_one/has_many/belongs_to relationships (eg has_many :campaigns -> has_many :distributions) - Yes
- Update :through relationships - Yes
- Update relationships in classes that have a relationship with from - Yes
- Update all classes that inherit from Campaign (class EmailCampign < Campaign -> class EmailCampaign < Distribution) - Yes
- Create rename_table migration for main model table - Yes
- Create rename_table migration for all relevant pivot/join tables - Yes
- Create migration to rename foreign keys (eg email.campaign_id -> email.distribution_id) - Yes
- Run migrations # TODO -> Add as an option
- Update view folder (views/campaigns/* -> views/distributions/*) - Yes
- Update controller file names (campaigns_controller.rb -> distributions_controller.rb) - Yes
- Update controller class names incl w/ namespacing (class Manage::CampaignsController < Manage::ApplicationController -> class Manage::DistributionsController < Manage::ApplicationController) - Yes
- Update routes (namespace campaigns -> namespace distributions) -> Yes
- Update paths (edit_manage_organisation_pressroom_pressdoc_campaign_path -> edit_manage_organisation_pressroom_pressdoc_distribution_path) - done
- Update URLs (edit_manage_organisation_pressroom_pressdoc_campaign_url -> edit_manage_organisation_pressroom_pressdoc_distribution_url) - done
- Change all references to that file (Campaign.blah_blah_blah -> Distribution.blah_blah_blah) (Global find and replace of
Campaign
toDistribution
) - done - Global find and replace of lower_case
campaign
todistribution
- done
- Here make certain to skip database folder - done
- This will Change all references from model -> model (@pressdoc.campaigns -> @pressdoc.distributions) -> Similar to above where it takes the file and replaces all instances of 'campaigns' with 'campaign'. It will also update instance variables (@campaign -> @distribution) - done
- Update specs (campaign_spec.rb -> distribution_spec.rb) - done
- Update factories (campaign_factory -> distribution_factory) - done
- Update factory name if in standalone file (pr_contact_factory.rb -> spokesperson_factory.rb)
- Run specs # TODO
- Update README to new name # TODO
- DO NOT replace UTF-8 characters with nil, as it will delete all UTF-8 characters in app
- Add in comprehensive logging so you can see what is happening at each point of code
- Write more tests
- Rewrite gem readme so that it is understandable
- Fill in accurate description and summary in rubygems
Other notes:
Could be issues with relations in non-model files.
Eg company.campaigns in the orders controller
Here --^ look for all associations and check the type of the caller. Not strictly a necessity as the type of the caller is what matters most not the name (eg company vs c)
Check if app uses devise and then if current user is being changed change that as well? # TODO