DEV Community

austinmei5
austinmei5

Posted on

Photogram Industrial

  • Keep Devise gem outside of the development group in the Gemfile. We want to use Devise in our production app. Any gems used for development only will fall under the development group.

  • Gem groups allow us to specify Gems used in production vs. development

  • Command + K clears terminal

  • Under the 'change' method of the migration file, include: enable_extension("citext")

  • Then change username and email from 'string' to 'citext'. Most developers forget to do this! This removes case sensitivity from these two columns in the database.

  • Reminder that 'git acm ""' is an appdev shortcut for: "git add -A; git commit -m"

  • typically, we generate users model first using Devise

  • Use the command 'annotate --models' to use the Annotate Gem. This creates annotations in each of the Model files.

  • Use 'rails g annonate:install' to annotate models anytime we run 'rails db:migrate'

  • Reminder: each belongs_to should have an inverse has_many

  • https://blog.arkency.com/how-to-add-a-default-value-to-an-existing-column-in-a-rails-migration/

  • Wrap .destroy_all commands in the following manner:
    if Rails.env.development?
    User.destroy_all
    FollowRequest.destroy_all
    end

  • Keep in mind that we need to destroy children objects before parent objects

  • Unique use of shuttle operator:
    photos.fans << follower # pushing follower into the fans collection of the Photo

  • creates a record in the join table, adding user to collection of users under the 'likes' table

Top comments (0)