2013-09-30 2 views
1

Я сгенерировал страницу с помощью контроллера. Но когда я иду на localhost: 3000/pages/home. Я получил эту ошибку: ExecJS :: RuntimeError в Страницы # домаRuby on Rails ExecJS :: RuntimeError в Pages # home

@RyanBigg Хорошо вот полный код ошибки:

ExecJS::RuntimeError in Pages#home 

Showing C:/Users/Anishka/Desktop/test/myfirstapp/app/views/layouts/application.html.erb where line #6 raised: 


    (in C:/Users/Anishka/Desktop/test/myfirstapp/app/assets/javascripts/pages.js.coffee) 
Extracted source (around line #6): 

3: <head> 
4: <title>Myfirstapp</title> 
5: <%= stylesheet_link_tag "application", :media => "all" %> 
6: <%= javascript_include_tag "application" %> 
7: <%= csrf_meta_tags %> 
8: </head> 
9: <body> 
Rails.root: C:/Users/Anishka/Desktop/test/myfirstapp 

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

Parameters: 

None 
Show session dump 

Show env dump 

Response 

Headers: 

None 

Я нашел решение здесь ExecJS::RuntimeError on Windows trying to follow rubytutorial

который:

The Fix that worked for us: On the system having issues, find ExecJS's runtimes.rb file. It looks like this. Make a copy of the found file for backup. Open the original runtimes.rb for editing. Find the section that starts with the line JScript = ExternalRuntime.new(. In that section, on the line containing :command => "cscript //E:jscript //Nologo //U", - remove the //U only. Then on the line containing :encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE - change UTF-16LE to UTF-8 . Save the changes to the file. This section of the file should now read:

JScript = ExternalRuntime.new( :name => "JScript", :command => "cscript //E:jscript //Nologo", :runner_path => ExecJS.root + "/support/jscript_runner.js", :encoding => 'UTF-8' # CScript with //U returns UTF-16LE) Next, stop then restart your Rails server and refresh the page in your browser that produced the original error. Hopefully the page loads without error now.

Но где файл runtimes.rb? Я не мог найти ничего подобного. Я начинаю рельсы, и ваша помощь будет оценена, спасибо.

+0

ExecJS поддерживает эти среды выполнения: 'therubyracer - встроенный Google V8 ithin Рубин therubyrhino - Mozilla Rhino встроенный в JRuby Node.js Apple, JavaScriptCore - в комплекте с Mac OS X Microsoft Windows Script Host (JScript) ' –

+0

вы установили' therubyracer' камень –

+0

Пожалуйста, покажите нам полное сообщение об ошибке. Вам не хватает его части со своего поста. –

ответ

1

Вам необходимо изменить командную строку, используемую ExecJS для cscript. Это можно сделать в файле runtimes.rb gem. Для меня это было расположено в:

C:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\execjs-2.0.2\lib\execjs

Естественно, это будет отличаться в зависимости от версии Ruby, и где он установлен.

Я нашел это обходным путем в a thread for an ExecJS issue.

Я изменил это:

JScript = ExternalRuntime.new(
    :name  => "JScript", 
    :command  => "cscript //E:jscript //Nologo //U", 
    :runner_path => ExecJS.root + "/support/jscript_runner.js", 
    :encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE 
) 

к этому:

JScript = ExternalRuntime.new(
    :name  => "JScript", 
    :command  => "cscript //E:jscript //Nologo", 
    :runner_path => ExecJS.root + "/support/jscript_runner.js", 
    :encoding => 'UTF-8' # CScript with //U returns UTF-16LE 
) 

Этот скриншот также из этого потока:

screenshot

Смежные вопросы