Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: rake db:seed aborted, no implicit conversion of nil into String

When I do the following:

rake db:drop
rake db:create
rake db:migrate
rake db:seed

This is what I get:

rake aborted!
no implicit conversion of nil into string    
app/mailers/base_mailer.rb:47:in '[]'
app/mailers/base_mailer.rb:47:in 'chimp_mail'

I think this has to do with mailchimp variables I have in my .env file. How would I pass these variables directly into bash?

like image 707
uralika Avatar asked Oct 16 '25 11:10

uralika


1 Answers

ENV

You can only use ENV variables if you have them available in your environment (OS). They are, after all, called environment variables:

Operating systems (Linux, Mac OS X, Windows) provide mechanisms to set local environment variables, as does Heroku and other deployment platforms. Here we show how to set local environment variables in the Unix shell. We also show two alternatives to set environment variables in your application without the Unix shell

I think your problem will likely be that you've not got your environment variables set up in such a way that your Rails app can access them in the backend


Figaro

I would try using Figaro

This is a gem which allows you to create & define any number of ENV variables, and have them accessible in your development environment. I would set the env variables in the application.yml file that's created with Figaro and try to run the db:seed command again

like image 66
Richard Peck Avatar answered Oct 18 '25 05:10

Richard Peck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!