问题
working on an api, using the rails-api and rabl gems, basing understanding off railscasts 348 and 322
currently getting
Missing template activities/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :rabl]}. Searched in:
* "/Users/jd/Dropbox/honeybadgerconsulting/activitiesapi/app/views"
but best I can tell, my setup mirrors the screencasts, is there a detail i'm overlooking ?
controller is
class ActivitiesController < ApplicationController
include ActionController::ImplicitRender
def index
@activities = Activity.all
end
end
and path to rabl template is /app/views/activities/index.json.rabl
context of json.rabl
collection @activities
attributes :title, :vendor, :date, :start_time, :price
![](https://www.eimg.top/images/2020/03/20/c8e54463d4e50e305e06797e36613c0f.png)
回答1:
Your request URL has to end in ".json", rails thinks it's an HTML request.
来源:https://stackoverflow.com/questions/21368905/why-wont-rails-find-rabl-templates