前提・実現したいこと
ターミナルで、 rails generate controller home top によってトップページを表示したい。
ここに質問の内容を詳しく書いてください。
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
Progate Ruby on Rails5 の手順通り、
ローカル環境 ターミナルにて rails generate controller home top 実行後、
localhost:3000/home/top にアクセスしたがエラーメッセージのため表示できない。
ルーティングが上手くいかない。
発生している問題・エラーメッセージ
ExecJS::ProgramError in Home#top TypeError: オブジェクトでサポートされていないプロパティまたはメソッドです。 showing .../sample_app/app/views/layouts/application.html.erb where line #7 raised: Extracted source (around line #7): <%= csrf_meta_tags %> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> </head> Rails.root: C:/Users/sanda/sample_app
該当のソースコード
ruby,
1application.html.erb コード 2 3<!DOCTYPE html> 4<html> 5 <head> 6 <title>SampleApp</title> 7 <%= csrf_meta_tags %> 8 9 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 10 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 11 </head> 12 13 <body> 14 <%= yield %> 15 </body> 16</html> 17 18 19 20 21 22 23 24 25 26routes.rb は以下のコード 27 28Rails.application.routes.draw do 29 get 'home/top' => "home#top" 30 31 # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 32end 33 34 35 36 37 38 39 40 41Gemfile コード 42 43source 'https://rubygems.org' 44 45git_source(:github) do |repo_name| 46 repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 47 "https://github.com/#{repo_name}.git" 48end 49 50 51# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 52gem 'rails', '~> 5.0.3' 53# Use sqlite3 as the database for Active Record 54gem 'sqlite3', '1.3.13' 55# Use Puma as the app server 56gem 'puma', '~> 3.0' 57# Use SCSS for stylesheets 58gem 'sass-rails', '~> 5.0' 59# Use Uglifier as compressor for JavaScript assets 60gem 'uglifier', '>= 1.3.0' 61# Use CoffeeScript for .coffee assets and views 62gem 'coffee-rails', '~> 4.2' 63# See https://github.com/rails/execjs#readme for more supported runtimes 64# gem 'therubyracer', platforms: :ruby 65 66# Use jquery as the JavaScript library 67gem 'jquery-rails' 68# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 69gem 'turbolinks', '~> 5' 70# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 71gem 'jbuilder', '~> 2.5' 72# Use Redis adapter to run Action Cable in production 73# gem 'redis', '~> 3.0' 74# Use ActiveModel has_secure_password 75# gem 'bcrypt', '~> 3.1.7' 76 77# Use Capistrano for deployment 78# gem 'capistrano-rails', group: :development 79 80group :development, :test do 81 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 82 gem 'byebug', platform: :mri 83end 84 85group :development do 86 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 87 gem 'web-console', '>= 3.3.0' 88end 89 90# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 91gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 92 93 94
試したこと
Node.jsなどいれたりしましたが上手くいきませんでした。
同様の問題がないか調べましたが、https://qiita.com/laineek/items/121a9a20d5eb26fb56f4
結局どうすればいいのかわかりません。
rails s でサーバー起動後
http://localhost:3000/ では
Ruby on Railsを表示できています。
http://localhost:3000/home/top ではエラーで表示できません
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
環境
Windows10
コマンドプロンプト
Atomエディタ使用
回答1件
あなたの回答
tips
プレビュー