Load and use fixture in rails console

You should be able to load your fixtures prior to entering console. Like this: RAILS_ENV=test bin/rails db:fixtures:load RAILS_ENV=test bin/rails console However, you still won’t be able to access your fixture data like you would in a test. This simply loads your test database with your fixtures data. So you’d still have to do something like: … Read more

How to enable auto completion in Ruby’s IRB

Just drop require ‘irb/completion’ in your irbrc. If that doesn’t work try bond, http://tagaholic.me/bond/: require ‘bond’; require ‘bond/completion’ Bond not only improves irb’s completion, http://tagaholic.me/2009/07/22/better-irb-completion-with-bond.html, but also offers an easy dsl for making custom autocompletions.

How can I reload a script in IRB?

In irb, File.expand_path(__FILE__)} will just return “#{path you ran irb from}/(irb)”. Which creates a path that doesn’t actually exist. Luckily all file paths are relative to where you ran irb anyway. This means all you need is: load “lib/query.rb” If you want to use the __FILE__ in an actual file, that’s fine, but don’t expect … Read more

How to run a .rb file from IRB?

You can “run” a file in irb by just requiring or loading it. $ irb >> load ‘./filename.rb’ To change your current working directory within irb, you can use FileUtils: >> require ‘fileutils’ >> FileUtils.pwd # prints working directory >> FileUtils.cd ‘/path/to/somewhere’ # changes the directory

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)