1

Hello I am new to Ruby on Rails. Here is my Setup on my Windows 10 machine

C:\Users\Jaiel>ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]

C:\Users\Jaiel>sqlite3 --version
3.8.7.2 2014-11-18 20:57:56 2ab564bf9655b7c7b97ab85cafc8a48329b27f93

C:\Users\Jaiel>rails --version
Rails 5.1.6

I am following the step by step tutorial form http://guides.rubyonrails.org/getting_started.html but I get an Error

I've run

C:\Users\Jaiel\Desktop\Test>rails new blog

Then I ran

C:\Users\Jaiel\Desktop\Test>cd blog
C:\Users\Jaiel\Desktop\Test\blog>rails server

And opened

http://localhost:3000/ 

and saw the "Yay, You're on Rails" Webpage

Then Ive ran

C:\Users\Jaiel\Desktop\Test\blog>rails generate controller Welcome index
  create  app/controllers/welcome_controller.rb
   route  get 'welcome/index'
  invoke  erb
  create    app/views/welcome
  create    app/views/welcome/index.html.erb
  invoke  test_unit
  create    test/controllers/welcome_controller_test.rb
  invoke  helper
  create    app/helpers/welcome_helper.rb
  invoke    test_unit
  invoke  assets
  invoke    coffee
  create      app/assets/javascripts/welcome.coffee
  invoke    scss
  create      app/assets/stylesheets/welcome.scss

I opened the

app/views/welcome/index.html.erb 

file in my text editor. Deleted all of the existing code in the file, and replaced it with the following single line of code:

<h1>Hello, Rails!</h1>

I then opened the file

config/routes.rb 

in my editor and edited it to look like this:

Rails.application.routes.draw do
get 'welcome/index'
root 'welcome#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

But now when I start the server

C:\Users\Jaiel\Desktop\Test\blog>rails server

and go to

http://localhost:3000/

Now comes the Error:

in the console and the error page it the says

Started GET "/" for 127.0.0.1 at 2018-04-23 18:05:56 +0200
Processing by WelcomeController#index as HTML
Rendering welcome/index.html.erb within layouts/application
Rendered welcome/index.html.erb within layouts/application (0.5ms)
Completed 500 Internal Server Error in 371ms

ActionView::Template::Error (TypeError: Das Objekt unterstützt diese Eigenschaft oder Methode nicht.):
4:     <title>Blog</title>
5:     <%= csrf_meta_tags %>
6:
7:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9:   </head>
10:

app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__839057971_94964316'

So line 7 gives the Error here :(

The Error is translated from german to

(TypeError: Object doesn't support this property or method)

It is because of the line

root 'welcome#index'

that I added into

C:\Users\Jaiel\Desktop\Test\blog\config\routes.rb

What is wrong here. Its the pofficial guide and the first Hello World Example but its already messed up...

Update: I removed the line

//= require_tree .

from

C:\Users\Jaiel\Desktop\Test\blog\app\assets\javascripts\application.js

and it worked. But this is a ridiculous solution as stated here ExecJS::RuntimeError on Windows trying to follow rubytutorial

Ilja KO
  • 1,272
  • 12
  • 26
  • Could you translate that error? It doesn't appear to be related to routing. – tadman Apr 23 '18 at 16:18
  • edited it @tadman – Ilja KO Apr 23 '18 at 16:21
  • also it only works when I dont add this line and leave it as it is. So no routing for me I guess...onto the next Webframework solution :D jk – Ilja KO Apr 23 '18 at 16:23
  • Googling the English translation of the error message turns up a bunch of Stack Overflow questions suggesting that this is a Windows-specific issue and offering a few solutions. This one looks like a good starting point: https://stackoverflow.com/questions/12520456/execjsruntimeerror-on-windows-trying-to-follow-rubytutorial/14118913#14118913 – mikej Apr 23 '18 at 16:30
  • Run `bundle install` then start the server again, just in case try to change `root to: "welcome#index"` – fool-dev Apr 23 '18 at 16:38
  • Also try to removing `require self` or `tree` from `application.js` then restart the server, it happaned many cases, just googling and apply this – fool-dev Apr 23 '18 at 16:41
  • @mikej I did and it worked *shaking my head* – Ilja KO Apr 23 '18 at 16:41
  • @fool-dev thank you for your help the remocing line did it. I updated and will report that this question is allready answered elsewhere – Ilja KO Apr 23 '18 at 16:42
  • Well Done :) See this [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – fool-dev Apr 23 '18 at 16:44

0 Answers0