0

I'm new in Rails, so I'm following tutorials from Michael Hartl. Currently I'm stuck on Chapter 2 The problem begins from Section 2.2

I generate the Users scaffold as instructed in the text, and then use rake db:migrate to apply migrations to database. However attempting to view the users after starting the server gives me an error:

ExecJS::RuntimeError in Users#index
Showing C:/Sites/rails_projects/demo_app/app/views/layouts/application.html.erb where line #6 raised:


  (in C:/RailsInstaller3.0/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/turbolinks-1.1.1/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line #6):
3
4
5
6
7
8
9

  <head>
    <title>DemoApp</title>
    <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
    <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
    <%= csrf_meta_tags %>
  </head>
  <body>

Rails.root: C:/Sites/rails_projects/demo_app

Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___308270545_35424396'

It does the same thing if I attempt to view any of the other pages that Michael's tutorial instructs. I'm not sure where to begin trying to debug this. Any help would be greatly appreciated.

Git repository is here: https://github.com/Tritonis/demo_app

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
TomP
  • 133
  • 1
  • 2
  • 12
  • 1
    please add your code to the post (not just the links) – Uri Agassi Jun 26 '14 at 19:41
  • I've heard of two fixes: 1) In your Command Line, install `nodejs`, with `gem install nodejs`. Then restart your server. 2) add the gem `therubyracer` to your Gemfile and run `bundle install` In both fixes, make sure you restart your server. credits: http://stackoverflow.com/a/8882423/2456549 – Justin Jun 26 '14 at 19:41
  • possible duplicate of [Error when running rails app - ExecJS::RuntimeError](http://stackoverflow.com/questions/8362458/error-when-running-rails-app-execjsruntimeerror) – nzifnab Jun 26 '14 at 20:12

1 Answers1

1

I've stumbled into this problem before. Installing therubyracer gem fixed it for me.

In your Gemfile, add: gem 'therubyracer', platforms: :ruby

Then, in your terminal, execute: bundle install and restart your server. The problem should be fixed.

Hope that helped!

Ilija Eftimov
  • 790
  • 8
  • 16
  • I'm a bit confused. I added it to my gemfile, and executed bundle install. I don't think the gem installed however, and I"m still having the problem with the server. Gemfile is here: http://pastebin.com/fAx6YSXY Not sure what I'm missing. I also tried gem install therubyracer, but that didn't work either. – TomP Jun 27 '14 at 17:50
  • Try installing Node.js: http://www.nodejs.org/download/ Make sure you restart your computer after installing, and try again. – Ilija Eftimov Jun 27 '14 at 19:42