DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on

3 1

rails with spring on direnv

I like Spring

It makes up your development speed by preloading the code.

I highly recommend you to use Spring.

Then, I've installed "Direnv".

It's environment variables management tool by each directory.
When you change the directory, it changes environment variables immediately.

It means, you need not to type 'bin' anymore 😀

# before
bin/rspec spec/xxx_spec.rb

# after
rspec spec/xxx_spec.rb

How to install and use it?

0. Suppose

I suppose we use 'Mac OSX'

1. install

brew install direnv

2. setup

Open your ~/.bash_profile and write it.

# Direnv
eval "$(direnv hook bash)"

Make .envrc file at root directory of your app.

touch .envrc
echo 'PATH_add bin' > .envrc

Then, you'll see following message.

direnv: error /Users/your_name/your_app/.envrc is blocked. Run `direnv allow` to approve its content

So, Run it.

direnv allow

3. try using it

rspec spec/xxx_spec.rb

Finish 🎉

Not only this

It seems more nice useful ways to use.
i.e, docker with direnv.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
gaultierq profile image
Quentin Gaultier

nice post

Collapse
 
codesalley profile image
Code Salley

there's no instruction as how to deploy a docker container with direnv.

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay