更新: 科林建议删除行// = require_tree.已经解决了这个问题.
我已经浪费了2天时间试图跟踪每个建议并解决我的问题.我试图按照Windows机器上的http://ruby.railstutorial.org书籍,并且不能为我的生活经历以下讨厌的错误.
ExecJS::RuntimeError in Static_pages#home
Showing C:/Users/.../bootcamp-sample-app/app/views/layouts/application.html.erb where line #6 raised:
["ok","(function() {\n\n\n\n}).call(this);\n"]
(in C:/Users/.../bootcamp-sample-app/app/assets/javascripts/sessions.js.coffee)
Extracted source (around line #6):
3: <head>
4: <title><%= full_title(yield(:title)) %></title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: <%= render 'layouts/shim' %>
9: </head>
Rails.root: C:/Users/.../bootcamp-sample-app
Application Trace | Framework Trace | Full Trace
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___487732698_30422172'
Request
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有的建议,包括用msi安装nodejs,使用execjs 1.3.0和其他我甚至不记得的东西.这是gem文件
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.0.0'
gem …Run Code Online (Sandbox Code Playgroud) 我正在通过入门教程(创建一个博客)和link_to Destroy无法正常运行.在终端中,它总是将其解释为#SHOW.
在阅读类似问题时,我了解到删除必须转换为POST以供浏览器解释.这似乎没有发生.
我也在Lynda.com Rails课程中使用Destroy遇到了同样的问题,所以它让我相信它是我开发环境中的东西.我在MacBook Pro Lion上使用Rails 4,Ruby 2.00p274,MySQL,WEBrick作为HTTP服务器.
在选择Destroy时的终端会话中:
Started GET "/posts/4" for 127.0.0.1 at 2013-08-09 13:45:20 -0600
Processing by PostsController#show as HTML
Parameters: {"id"=>"4"}
Post Load (0.6ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1 [["id", "4"]]
Rendered posts/show.html.erb within layouts/application (0.4ms)
Completed 200 OK in 13ms (Views: 8.6ms | ActiveRecord: 0.6ms)
Run Code Online (Sandbox Code Playgroud)
在ports-controller.rb中:
def destroy
@post = Post.find(params[:id])
@post.destroy
redirect_to action: :index
end
Run Code Online (Sandbox Code Playgroud)
在index.html.erb中:
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.text %></td> …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) 我创建了一个数据库(空)的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)