DEV Community

loading...

Ruby/Rails Machine Setup Guide

hasanadeem profile image Hasan Nadeem ・3 min read

1- IDE

We prefer to use sublime/VS Code for development(you can opt for any IDE though, but that will mean no support from seniors for any issues relating it and that might lead to un-neccessary time waste thats why it is highly preferred to not use any other IDEs). You are encouraged to use sublime or VSCode.

Sublime:

Install Sublime3 (google or use this link)
Here we will outline some basic configuration for sublime3 we usually use.

i- Settings Tweaks
In sublime go to preferences->settings and place these in user settings tab along with other settings.
Don't mess with default settings tab

{
  "auto_complete_commit_on_tab": true,
    "auto_complete_triggers":
    [
        {
            "characters": "b4",
            "selector": "text.html"
        }
    ],
    "auto_indent": true,
    "caret_style": "phase",
    "color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
    "draw_minimap_border": true,
    "draw_white_space": "all",
    "enable_tab_scrolling": false,
    "ensure_newline_at_eof_on_save": true,
    "file_exclude_patterns":
    [
        "*.pyc",
        "*.pyo",
        "*.exe",
        "*.dll",
        "*.obj",
        "*.o",
        "*.a",
        "*.lib",
        "*.so",
        "*.dylib",
        "*.ncb",
        "*.sdf",
        "*.suo",
        "*.pdb",
        "*.idb",
        "*.class",
        "*.psd",
        "*.db",
        "*.beam",
        ".DS_Store",
        ".tags"
    ],
    "folder_exclude_patterns":
    [
        ".svn",
        ".git",
        ".hg",
        "CVS",
        ".sass-cache"
    ],
    "font_options":
    [
        "gray_antialias"
    ],
    "font_size": 15,
    "gutter": true,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "ignored_packages":
    [
        "CoffeeScriptHaml",
        "Emmet",
        "ESLint",
        "Markdown",
        "Ruby Completions",
        "SublimeLinter-contrib-eslint_d",
        "SublimeLinter-eslint",
        "Vintage"
    ],
    "line_numbers": true,
    "line_padding_top": 0,
    "mouse_wheel_switches_tabs": false,
    "overlay_scroll_bars": "enabled",
    "preview_on_click": true,
    "rulers":
    [
        120
    ],
    "scroll_past_end": false,
    "show_tab_close_buttons": false,
    "tab_size": 2,
    "theme": "Adaptive.sublime-theme",
    "translate_tabs_to_spaces": true,
    "trim_automatic_white_space": true,
    "trim_trailing_white_space_on_save": true,
    "use_tab_stops": true,
    "wide_caret": true,
    "word_separators": "./\\()\"'-:,.;<>@#$%^&*|+=[]{}`",
    "indent_using_spaces": true,
    "index_files": true,
    "line_padding_bottom": 2,
    "line_padding_top": 0,
    "rulers":
    [
        90,
        100,
        120
    ],
    "show_sidebar_on_save": false,
    "spell_check": true,
    "tab_width": 2,
    "word_wrap": false
}
Enter fullscreen mode Exit fullscreen mode

Have an eye for any redundency in settings and replace that if there is any.

This will make indentation more easy, as indentation is one of the most important things for code quality and useability.

ii- Sublime Package Control
Install package control following:
This link

After that, you can access package control in preferences and install any package you need(Like gitgutter, A file icon, beautifyruby, brackethighlighter etc).

Here is the list of some handy packages in sublime, you can install them in some spare time. Not required but helpful for development.
iii- Useful Sublime Packages:

A File Icon
All Autocomplete
Better CoffeeScript
Bootstrap 3 Autocomplete
BracketHighlighter
Cucumber Step Finder
Cucumber
Dockerfile Syntax Highlighting
Emmet
GitGutter
HTMLBeautify
Javascript Beautify
MarkdownEditing
Package Control
RecentActiveFiles
RSpec
RuboCop
Ruby Hash Converter
Ruby Slim
Sass
SassBeautify
SCSS
SideBarEnhancements
SublimeLinter-contrib-scss-lint
SublimeLinter-rubocop
YAML Nav
Enter fullscreen mode Exit fullscreen mode

VSCode:

Download and install VSCode from here

Recommended settings for VSCode:

    "ruby.useLanguageServer": true,
    "ruby.format": "rubocop",
    "ruby.intellisense": "rubyLocate",
    "ruby.useBundler": true,
    "ruby.rubocop.useBundler": true,
    "[ruby]": {
        "editor.defaultFormatter": "misogi.ruby-rubocop"
    },
    "editor.tabSize": 2,
    "files.insertFinalNewline": true,
    "telemetry.enableTelemetry": false,
    "window.titleBarStyle": "custom",
    "files.trimTrailingWhitespace": true,
Enter fullscreen mode Exit fullscreen mode

Add these settings in File > Preferences > Settings (open the settings in json)

Following are some recommended extension for VScode. Please run the following commands on terminal for installing the extensions:

code --install-extension castwide.solargraph
code --install-extension dbaeumer.vscode-eslint
code --install-extension donjayamanne.githistory
code --install-extension eamodio.gitlens
code --install-extension HookyQR.beautify
code --install-extension IBM.output-colorizer
code --install-extension mhutchie.git-graph
code --install-extension misogi.ruby-rubocop
code --install-extension rebornix.ruby
code --install-extension wheredoesyourmindgo.gruvbox-concoctis
code --install-extension wingrunr21.vscode-ruby
Enter fullscreen mode Exit fullscreen mode

You can install these through command line, one by one using the command: code --install-extension $EXT_NAME.

2- Ruby environment/version manager with Rails Setup

Link for Ruby/Rails/Rbenv/Postgres Setup
Note: Please do the following while going through the above article.

  1. Please install and use RBENV. Skip RVM
  2. Please install Ruby version 2.6+ / Rails version 6 / Postgres version 11
  3. Please set the Postgres username to postgres with password postgres - MUST
  4. Please skip Configuring Git

3- Database

It is preferred to use postgresql dbms for development, as it is a de-facto standard in most rails applications. Books may be using sqlite 3 but it is encouraged to use postgresql.

TIP: If you keep an eye on what these commands actually are doing, that will be beneficial for you. Like you can give 2-4 mins on reading about apt-get and what it actually does, give 2 minutes to read about sudo or any new command like curl if you don't know about it, this will help you grip ubuntu/linux quickly.

Terminal

  1. For Fancy/Pretty Diff -> https://github.com/so-fancy/diff-so-fancy
  2. For common git aliases, run the following commands on terminal:
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
Enter fullscreen mode Exit fullscreen mode

NOTE: Some parts of this guide are extracted from https://gist.github.com/ziaulrehman40/16445c56e3f7bc7d1dece245fb61cf8e

Discussion (2)

pic
Editor guide
Collapse
jsrn profile image
James

It'd be good to know why you recommend some of these settings and extensions over the alternatives.

Collapse
hasanadeem profile image
Hasan Nadeem Author

Sure! I'll add up the missing details.