Reputation: 1185
so I am very new to ruby and rails and I'm following this tutorial exactly: http://guides.rubyonrails.org/getting_started.html
I am having trouble with the basic "Hello, Rails!" output on the localhost:3000 as even when I follow along and make the appropriate changes to
app/views/welcome/index.html.erb
and
config/routes.rb
localhost:3000 still displays the default Ruby on Rails Welcome screen instead of "Hello, Rails!"
in the file
app/views/welcome/index.html.erb
I have the following code:
<h1>Hello, Rails!</h1>
in the file
config/routes.rb
I have the following code:
Blog::Application.routes.draw do
get "welcome/index"
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
root :to => 'welcome#index'
end
and I initially generated the controller with
rails generate controller welcome index
Thank you!
EDIT:
I removed the public/index folder and now get the following error in the browser:
ExecJS::RuntimeError in Welcome#index
Showing C:/blog/app/views/layouts/application.html.erb where line #6 raised:
(in C:/blog/app/assets/javascripts/welcome.js.coffee)
Extracted source (around line #6):
3: <head>
4: <title>Blog</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
Rails.root: C:/blog
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb__607271608_36500496'
EDIT 2:
rake routes gives:
welcome_index GET /welcome/index(.:format) welcome#index
root / welcome#
EDIT 3:
source of welcome.js.coffee:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
source of Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
Upvotes: 1
Views: 1657
Reputation: 71
If you are not planning to use turbolinks you can avoid installation of turbolinks with rails by running new your_project_name --skip-turbolinks
when creating your rails project. This way you will avoid this kind of bugs while you are learning the basics.
Upvotes: 1
Reputation: 1
yes,truly worked for me. deleted following line from C:/blog/app/views/layouts/application.html.erb
:
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Upvotes: 0
Reputation: 1185
Solved it:
go to
C:/blog/app/views/layouts/application.html.erb line #6
and remove the javascript line.
But this is really stupid and I think the real solution is to switch to linux.
Upvotes: 0
Reputation: 10208
Check if your controller file is welcome_controller.rb. Also Check if the class name is "WelcomeController".
EDIT:
It seems that you are getting a ExecJS exception. Please add a javascript runtime to the gemfile:
gem 'therubyracer'
I hate windows.
Upvotes: 1