Renaissance Rogue Renaissance Rogue - 3 months ago 20
Ruby Question

I'm following the learn-rails tutorial book 2 from http://learn-rails.com/

I am a beginner!

I keep getting this error in Terminal when I start rails server:

rails server localhost:3000

Exiting
/Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/handler.rb:78:in `require': cannot load such file -- rack/handler/localhost:3000 (LoadError)
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/handler.rb:78:in `try_require'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/handler.rb:16:in `get'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/rack-1.6.4/lib/rack/server.rb:290:in `server'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:125:in `print_boot_information'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/server.rb:75:in `start'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/michael/Projects/RailsApps/learn-rails/bin/rails:9:in `require'
from /Users/michael/Projects/RailsApps/learn-rails/bin/rails:9:in `<top (required)>'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/michael/Projects/RailsApps/learn-rails/bin/spring:13:in `require'
from /Users/michael/Projects/RailsApps/learn-rails/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'


I'm on a 2013 MacBook Air running OSX EL Cap 10.11.6
rvm 1.27.0
ruby 2.3.1
rails 4.2.5
I am running rails server from Projects/RailsApps/learn-rails. I am working through chapter 10 Configure and had set my environmental variables in .bashrc and configured the config/secrets.yml file to pull from the environmental variables.
I have tried googling for help but could not find any answers that pertain.
I also could not find an answer on SO or Quora that could help me out.

**UPDATE
This is the error message i receive after running 'bundle' and 'rails g simple_form:install'

Michaels-MacBook-Air:learn-rails michael$ rails g simple_form:install
[Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.
/Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/erb.rb:864:in `eval': (erb):15: syntax error, unexpected '=', expecting end-of-input
; =ENV["SENDGRID_PASSWORD"] ; _e...
^ (SyntaxError)
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/erb.rb:864:in `result'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application.rb:391:in `secrets'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application.rb:178:in `key_generator'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application.rb:206:in `message_verifier'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/globalid-0.3.7/lib/global_id/railtie.rb:25:in `block (2 levels) in <class:Railtie>'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/activesupport-4.2.5/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
from /Users/michael/Projects/RailsApps/learn-rails/config/environment.rb:5:in `<top (required)>'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application.rb:92:in `require'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application.rb:92:in `preload'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /Users/michael/.rvm/gems/ruby-2.3.1@learn-rails/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/michael/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'


I have checked my gemfile.
gem simple_form
is listed and uncommented from gemfile.

Answer

I think that in your secrets.yml file, you have something like this.

<% =ENV["SENDGRID_PASSWORD"] %>

=ENV["SENDGRID_PASSWORD"] is not a valid ruby expression and thats why you're getting the error.

It should actually be

<%= ENV["SENDGRID_PASSWORD"] %>

Hope this helps!