我在Surface Pro 3上安装了Rails,并在尝试查看页面后遇到此错误。我尝试了一些建议,例如使用libv8安装rubyracer,但没有帮助。
TypeError:对象不支持此属性或方法(在c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js中。咖啡)
这是我的gemfile:
source 'http://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.8' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc gem 'libv8', '~> 3.16.14.7' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Use debugger # gem 'debugger', group: [:development, :test] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin] gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' gem 'font-awesome-rails' gem 'simple_form' gem 'devise'
与流行的看法相反,Rails并不像声称的那样跨平台兼容。如果是这样,则可以在Windows上正常使用。像您一样,我尝试了所有可用选项。
这是使用Ruby 2.1.5p273 / Rails 4.2.0解决的
我将execjs更改为将UTF-8与jscript一起使用,没有效果。通过编辑 C:\ RailsInstaller \ Ruby2.1.0 \ lib \ ruby \ gems \ 2.1.0 \ gems \ execjs-2.2.2 \ lib \ execjs \ runtimes.rb 来完成此操作,将JScript =块更改为以下内容。
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 )
我还尝试安装therubyracer,这导致libv8依赖项无法编译的问题。我将python 2.7安装添加到Windows系统路径中,并安装了libv8。然后它说libv8已安装,但是当我尝试安装therubyracer时说找不到libv8。我卸载了libv8,然后重试,它说libv8无法编译。这足以让我确定therubyracer将无法在Windows上运行,因此我将其从Gemfile中注释掉,而将python 2.7保留在Windows系统路径中。
通过将以下内容添加到我的Gemfile中,我更新了coffee-script-source
gem 'coffee-script-source', '1.9.0'
在将coffee-script-source添加到我的Gemfile中之后,我运行了 gem update coffee-script-source ,这也没有解决问题。
然后,我安装了node.js,它工作了5分钟,直到生成新的控制器,然后再次损坏。
注意:在安装node.js之后,您需要打开一个新的命令提示符,以获取在安装node.js时设置的系统路径更新。
最后,解决此问题的方法是打开 app \ assets \ javascripts \ application.js 文件并删除最后一行,
// = require_tree。
最后运行以下命令,以确保在Node.js中正确安装coffee-script
npm install -g coffee-script