Reputation: 311
Trying to get User model to print to JSON, tried making a file with a json.rabl extension as follows:
file.json.rabl
object @users
attributes :id, :name
When I try to view this, I get the following error message:
Missing template users/autocomplete, application/autocomplete with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :rabl, :rb]}.
However, if I rename the file to file.rabl, it renders the JSON, but in an HTML page instead. How do I get it to print a pure JSON file?
Here is my controller code for the file view:
def file
@users = User.all
respond_to do |format|
format.html
format.json
end
Upvotes: 0
Views: 587