【发布时间】:2016-10-12 04:09:26
【问题描述】:
我是 Ruby on Rails 的新手,正在尝试建立一个超级简单的数据库。
我得到了一个
ProfilesController#index 中的 ActionController::UnknownFormat
ProfilesController#index 缺少此请求格式和变体的模板。 request.formats: ["text/html"] request.variant: [] 注意!对于 XHR/Ajax 或 API 请求,此操作通常会响应 204 No Content:一个空白屏幕。由于您是在 Web 浏览器中加载它,我们假设您希望实际呈现一个模板,而不是……什么都没有,所以我们显示一个错误以非常清楚。如果您期望 204 No Content,请继续。这就是您将从 XHR 或 API 请求中获得的信息。试一试。
错误,我不确定发生了什么。我尝试研究,但我不知道我做错了什么。
#profiles_controller.rb:
class ProfilesController < ApplicationController
def index
@profiles = Eprofiles.all
end
end
#routes.rb:
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get 'welcome', to: 'pages#home'
get 'profiles', to: 'profiles#index'
end
#eprofiles.rb
class Eprofiles < ApplicationRecord
end
【问题讨论】:
-
可以是
EProfile.all吗?模型是单数,而不是复数是 Rails 约定
标签: ruby-on-rails ruby