Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Could not find generator figaro:install"

I'm using the "Learn Ruby On Rails" pdf book from learn-rails.com.

I'm at chapter 13, "Configure". Where we are supposed to do the command: "rails generate figaro:install"

In chapter 12 we installed the figaro gem,: "We’ve already installed the figaro gem in the Gemfile and run bundle install."

When I run that command I get: "Could not find generator figaro:install."

I started searching for similar questions, and I did find this question here: rails generate - "Could not find generator" where they were recommended to include "migration" into the command as well.

I included it in my command and I got it to do something, but I don't think it's doing what it should be?

invoke  active_record
/Users/NormalUse/.rvm/gems/ruby-2.0.0-p353@learn-rails/gems/activerecord-4.0.2/lib/rails/generators/active_record/migration/migration_generator.rb:57:in `validate_file_name!': Illegal name for migration file: figaro:install (ActiveRecord::IllegalMigrationNameError)
(only lower case letters, numbers, and '_' allowed)
from /Users/NormalUse/.rvm/gems/ruby-2.0.0-p353@learn-rails/gems/activerecord-4.0.2/lib/rails/generators/active_record/migration/migration_generator.rb:10:in `create_migration_file'

Then about 20 more lines as well. I just didn't want to put it all here.

The author goes on to say:

"Using the rails generate command, the figaro gem generates a config/application.yml file and lists it in your .gitignore file. The .gitignore file prevents the config/application.yml file from being saved in the Git repository so your credentials are kept private."

When I go to my project directory, and look inside the "config" folder, I do have an "application" file, but it ends with ".rb" and not "yml". So obviously the command didn't do what it is supposed to do, right?

Does anyone have any ideas for me?

I'm using Ruby 2.0.0 and Rails 4.0.2 with RVM on Mac OSX 10.7.5

like image 670
Anthony Myers Avatar asked Jan 22 '14 05:01

Anthony Myers


2 Answers

If you do this tutorial nowadays instead of "rails generate figaro:install" run command "figaro:install" due to figaro 1.0.0 version https://github.com/laserlemon/figaro

like image 85
animsaj Avatar answered Sep 27 '22 23:09

animsaj


As you're learning (welcome to the Rails community btw!), let me explain what Figaro does & how to use (install) it:


Figaro

Figaro is a way to create ENV variables in both development & production. It's a gem which you have to install before invoking from the Rails cmd

Like other Ruby gems in Rails, you have to add it to your Gemfile, which lists all the plugins your app will use. According to RubyGems.org, you could list it in your Gemfile like this:

#Gemfile
gem "figaro", "~> 0.7.0"

After you've added this line to your Gemfile, you need to install it. To do this, you should run bundle install to run the bundler (installer)

Once you've done this, you need to run this command from cmd:

rails generate figaro:install

Error

Your errors seem to indicate you've got migration problems?

Illegal name for migration file: figaro:install (ActiveRecord::IllegalMigrationNameError)

I would guess you called this command:

rake db:migrate figaro:install

If this is the case, you should perform any migrations by running rake db:migrate and then rails generate figaro:install. This will run the commands separately, which should help them work

like image 41
Richard Peck Avatar answered Sep 27 '22 23:09

Richard Peck