新手问题 Jbuilder 在服务器上总是 template is missing

autumnwolf · 2014年12月23日 · 最后由 autumnwolf 回复于 2014年12月25日 · 2520 次阅读

折腾了好久,还是没能解决这个问题,服务器上运行的是 staging 环境, 本地通过 rails s -e production/staging/development 都是可以正确返回 json 数据: 错误如下:

Template is missing

Missing template instigates/index, application/index with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder, :arb, :jbuilder, :rabl]}. Searched in: * "/home/yzhang/instigatestaging/instigateweb/app/views" * "/home/yzhang/.rvm/gems/ruby-2.1.5/gems/activeadmin-0.6.3/app/views" * "/home/yzhang/.rvm/gems/ruby-2.1.5/gems/kaminari-0.16.1/app/views" * "/home/yzhang/.rvm/gems/ruby-2.1.5/gems/devise-3.4.1/app/views"


这里的方法也不好用 http://stackoverflow.com/questions/10520269/rails3-actionview-template-handlers-doesnt-work-on-production-server/13742784#13742784

Gemfile

source 'http://rubygems.org'
gem 'rails', '3.2.13'
gem 'rake','10.0.0'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

group :development, :test do
  gem "factory_girl_rails", "~> 4.0"
  #gem "sqlite3"
  gem "shotgun"
end

group :test do
  gem 'mocha', :require => false
  gem 'rack-test'
  gem 'vcr'
  gem 'webmock'
end

gem 'jquery-rails'

gem 'mysql2'

# group :production do
#   gem 'mysql2'
# end

# Use unicorn as the app server
gem 'unicorn'

# Deploy with Capistrano
gem 'capistrano', '2.15.4'

gem 'rails-i18n'

gem 'simple_form'
gem 'country-select'

# gem "urbanairship"
# gem 'auto_migrations' #,:git => "https://github.com/subicura/auto_migrations.git"
# =======
gem "urbanairship", "~> 2.3.3"
gem 'auto_migrations' ,:git => "https://github.com/subicura/auto_migrations.git"
gem "formtastic" # ,:git => "https://github.com/justinfrench/formtastic.git"
gem 'activeadmin',  "~>0.6.2"
gem "meta_search",    '>= 1.1.0.pre'
gem 'devise'
gem "paperclip", "~> 3.5.3"
gem 'koala'
gem "rest-client"
gem 'delayed_job_active_record'
gem 'daemons'
gem 'rocket_pants', '~> 1.0'
gem "chronic"
#gem "active_model_serializers"
gem "multi_json"

gem 'rvm-capistrano'
gem 'rabl'
gem 'jbuilder', '2.2.6'

你的文件名是什么?

很有可能是文件名大小写不对...

@ruby_sky @luikore 应该是文件名问题,我的文件名 InstigatesController; 视图 views/instigate/show etc. 但是昨天最终我把 Controller 改成 InstigateController 就可以了 不知道为什么,如果不能工作的话不知道为什么本地都是好用的

需要 登录 后方可回复, 如果你还没有账号请 注册新账号