启动一个新的应用程序,当我创建一个控制器页面回家并尝试转到本地主机:3000/pages/home时,我收到以下错误:
Showing c:/Users/Doesha/desktop/pinplug/app/views/layouts/application.html.erb where line #6 raised:
TypeError: Object doesn't support this property or method
(in c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
Run Code Online (Sandbox Code Playgroud)
application.html.erb文件:
<!DOCTYPE html>
<html>
<head>
<title>Pinplug</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
application_controller.rb文件:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
Run Code Online (Sandbox Code Playgroud)
pages_controller.rb文件:
class PagesController < …Run Code Online (Sandbox Code Playgroud) 我在Surface Pro 3上安装了Rails,并在尝试查看页面后遇到此错误.我已经尝试了一些建议,比如用libv8安装rubyracer,但它没有帮助.
TypeError:Object不支持此属性或方法(在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 …Run Code Online (Sandbox Code Playgroud) 这似乎是一个重复的问题,但没有一个解决方案似乎适合我.我有gem jquery-rails我的Gemfile.还有,行
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
这是我的Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use SCSS for stylesheets
#gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
#gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as …Run Code Online (Sandbox Code Playgroud) 我正在尝试将登录注销功能添加到我的rails应用程序中.为此,我添加了bcrypt用于密码加密的gem以及访问控制器.现在当我在本地运行它时,我收到一条错误消息.在添加上述功能之前,我的应用运行正常.
错误信息:
TypeError: Object doesn't support this property or method
(in C:/DevKit/lib/ruby/gems/1.9.1/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line #8):
<head>
<title>PostApp</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track'=>true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track'=>true %> ----> Line 8
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<%= csrf_meta_tags %>
Run Code Online (Sandbox Code Playgroud)
的Gemfile:
source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
# Use …Run Code Online (Sandbox Code Playgroud) 您可以编译Java应用程序并在Java虚拟机所在的任何计算机上运行它,而与底层硬件无关.
由于Ruby on Rails是基于Ruby构建的,我担心在任何环境中使用Ruby构建软件是否相同.至少存在适用于Windows,Linux和Mac的Ruby版本.
那么,你可以用Ruby应用程序和Java应用程序做同样的事情吗?换句话说,跨平台是如何Ruby的?
编辑:我的意思是Ruby本身,而不是像jRuby一样在另一个虚拟机中运行Ruby .我是否期望在Ruby中开发比Java更多的跨平台陷阱或两者几乎相同?
我很抱歉询问可能是一个补救问题,但在学习rails时我试图按照本教程中的注释说明:
http://guides.rubyonrails.org/getting_started.html
我昨晚在本教程中发布了一个类似的问题并得到了一个迅速的回复,这对我帮助很大,所以我希望也能如此.先感谢您.
第5.14节:删除帖子
我被指示向index.html.erb页面添加删除链接
<h1>Listing Posts</h1>
<table>
<tr>
<th>Title</th>
<th>Text</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.text %></td>
<td><%= link_to 'Show', post_path %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', post_path(post),
method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
Run Code Online (Sandbox Code Playgroud)
产生:
<td><a data-confirm="Are you sure?" data-method="delete" href="/posts/1" rel="nofollow">Destroy</a></td>
Run Code Online (Sandbox Code Playgroud)
对我来说看起来不错,但是当我点击链接时,我既没有得到确认也没有指向删除操作.它会生成此HTTP操作
Request URL:http://localhost:3000/posts/1
Request Method:GET
Status Code:200 OK
Run Code Online (Sandbox Code Playgroud)
Rails:4,Ruby:2,64位windows 8,chrome:版本28.0.1500.72 m
再次感谢你
添加application.html.erb
<!DOCTYPE html>
<html> …Run Code Online (Sandbox Code Playgroud) 更新:事情正在发挥作用!
感谢深度,我安装了node.js然后得到了一个TZInfo :: DataSourceNotFound错误,通过添加gem 'tzinfo-data', platforms: [:mingw, :mswin]和解决了bundle update.
谢谢你,先生 !
首先,我是一个完全初学者的轨道(只是为了让你得到我的初学者:我觉得自己只是在这里张贴的专家)这是我的第一个问题,所以请原谅我,如果我不是很明确.
所以,我是一个Windows 7用户,学习使用One Month课程的rails,我在尝试时遇到错误:
$ rake routes
rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://git
hub.com/sstephenson/execjs for a list of available runtimes.
c:/Users/Marc Montagne/Desktop/pinteresting/config/application.rb:7:in `<top (re
quired)>'
c:/Users/Marc Montagne/Desktop/pinteresting/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
要么
$ rails server
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/run
times.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://gi
thub.com/sstephenson/execjs for a list of …Run Code Online (Sandbox Code Playgroud) 我创建了一个数据库(空)的rails应用程序.当我尝试查看我的产品页面时,我在http:// localhost:3000/products页面上收到以下错误.在迁移数据库之前,应用程序确实起作用.我正在使用therubyracer,我在Windows 7上.
ExecJS::ProgramError in Products#index
Showing C:/RailsInstaller/DevKit/home/JP/nameofapp/app/views/layouts/application.html.erb where line #16 raised:
TypeError: Object doesn't support this property or method
(in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
Extracted source (around line #16):
13 <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
14
15 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
16 <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
17 <%= csrf_meta_tags %>
18
19 </head>
Rails.root: C:/RailsInstaller/DevKit/home/JP/nameofapp
Run Code Online (Sandbox Code Playgroud)
这是我在Rails服务器上得到的:
Started GET "/products" for 127.0.0.1 at 2015-04-23 22:28:06 -0400
ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations".* FROM
"schema_migrations"
Processing by ProductsController#index …Run Code Online (Sandbox Code Playgroud) 我无法启动 Rails 服务器。显然我没有 JavaScript 运行时。
$ rails s
c:/Ruby22/lib/ruby/gems/2.2.0/gems/bundler-1.13.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Run Code Online (Sandbox Code Playgroud)
我去了链接
但我不知道该怎么做。那么我究竟如何“安装”一个 JavaScript 运行时呢?
这里也是我的 GemFile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
# Use …Run Code Online (Sandbox Code Playgroud) execjs ×4
javascript ×3
ruby ×3
windows ×2
assets ×1
html5 ×1
java ×1
jquery ×1
therubyracer ×1
turbolinks ×1
windows-10 ×1