部署在heroku上的rails 3.1项目出现问题

发布于 2024-12-15 23:59:13 字数 1458 浏览 3 评论 0原文

由于某种原因,我的项目中的 .js.coffee 文件没有通过 :remote => 调用true links/forms

我正在尝试通过 Ajax 调用 posts/new 控制器。控制器正在被调用并执行,但它找不到重定向到的位置。

在日志中我收到以下消息:

ActionView:MissingTemplate(缺少模板 posts/new、application/new,带有 {:handlers => [:erb, :builders], :formats => [:js, :html], :locale => [ :en, :en]} 搜索位置:*“/app/app/views”

当我将 new.js.coffee 文件更改为new.js 它工作正常。知道该怎么做才能运行 Coffee 脚本文件吗?

更新

我的 Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

group :development do
    gem 'sqlite3'
end

group :deployment do
    gem 'pg'
end

gem 'devise', '1.4.9'
gem 'omniauth', '1.0.0'
gem 'omniauth-facebook'
gem 'rails_autolink'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

For some reason my .js.coffee files in my project are not being called through the :remote => true links/forms

I'm trying to call the posts/new controller via Ajax. The controller is being called and executed but it can't find to where to redirect.

In the log I get the following message:

ActionView:MissingTemplate (Missing template posts/new, application/new with {:handlers => [:erb, :builders], :formats => [:js, :html], :locale => [:en, :en]}. searched in: * "/app/app/views"

When I change my new.js.coffee file to new.js it works fine. Any idea what to do so I can run Coffee script files too?

UPDATE

My Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

group :development do
    gem 'sqlite3'
end

group :deployment do
    gem 'pg'
end

gem 'devise', '1.4.9'
gem 'omniauth', '1.0.0'
gem 'omniauth-facebook'
gem 'rails_autolink'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.1.4'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假情假意假温柔 2024-12-22 23:59:13

将您的 gem 'coffee-rails' 行放在 :assets 组之外,也许放在您的 jquery-rails gem 行之后。 :assets gem 在生产过程中不会被使用。

Put your gem 'coffee-rails' line outside of the :assets groups, maybe down after your jquery-rails gem line. The :assets gems don't get used during production.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文