neovim Ruby on Rails - Lamtea/dotfiles GitHub Wiki

neovim Ruby on Rails

Preparation

Please complete the following tasks:

neovim Ruby.

How to execute

mkdir hello-rails
cd hello-rails
# Optional
# You can keep the version of asdf.
asdf local ruby <your version>
bundle init
bundle config --local path vendor/bundle
vi GemFile
gem 'rails' # Uncomment
bundle install
bundle exec rails new . # say 'Y'
# Terminal 1
bundle exec rails s
# Terminal 2
curl 'http://localhost:3000'

C-c in Terminal 1.

Coding

# Add controller
bundle exec rails g controller hello
vi app/controllers/hello_controller.rb
def index
@hello = "Hello World"
render template: "hello/index"
end
# Add view
vi app/views/hello/index.html.erb
<h1><%= @hello %></h1>
# Add routing
vi config/routes.rb
get "hello", to: "hello#index"
# Terminal 1
bundle exec rails s
# Terminal 2
curl 'http://localhost:3000/hello'

C-c in Terminal 1.

Debugging

nvim-dap-ruby rais Not Supported Yet.

Linting and Formatting

Ruby

The same as the following:

See: neovim Ruby -- Linting and Formatting.

eRuby

There are many settings:

See: erb-lint.

See also: better-html.

⚠️ **GitHub.com Fallback** ⚠️