0

First of all, I open the Windows command prompt with Ruby and Rails via the shortcut provided by RailsInstaller. First of all, I create a new Ruby on Rails application using the following command. I call it "curso"

rails new curso

After that, I navigate to the project folder C:\Sites\pruebaand start the WEBrick server, like this:

rails s

I go to localhost:3000and the test page runs perfectly.

After that, I import the project in NetBeans. Then, I open the command prompt and create a new controller, like this:

rails g controller miprueba index

I check the file Views/layouts/application.html.erb, which was generated by Rails and it looks like this:

<!DOCTYPE html>
<html>
  <head>
    <title>Prueba</title>
    <%= csrf_meta_tags %>

    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

NetBeans shows me an error on line 7. It says Unexpected ':'. The same error happens in line 8.

If I try running the application, in localhost:3000/miprueba/index, I get an error page titled "Action Controller: Exception caught". It says this:

ExecJS::ProgramError in Miprueba#index
Showing C:/Sites/prueba/app/views/layouts/application.html.erb where line #7 raised:

TypeError: El objeto no acepta esta propiedad o método

The last line roughly means "The object doesn't accept this value or method".

If I delete lines 7 and 8 the application runs just fine, but I'm curious about why are those two lines generated and why do they fail.

1 Answers1

0

The first error being thrown by NetBeans is likely a red herring. The error concerning the unexpected ':' is related to the use of colon-hash syntax on an escaped symbol in an implicit hash. ERB isn't technically ruby, so NetBeans is probably getting confused.

The real error is related to running ruby on rails on Windows. The error is actually being thrown by a javascript runtime, not rails. The short answer is that you can install NodeJS to replace your existing runtime with one that works well with Rails. Or you can follow the instructions here:

execjsruntimeerror-on-windows

Rails on Windows is tough. Good luck!

eiko
  • 5,110
  • 6
  • 17
  • 35
  • 1
    I chose the short approach (installing Node.js) and the problem is gone. Worked perfectly, thank you @eiko! –  Jun 28 '17 at 06:23