Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined local variable or method `json' in JBuilder

When I try get all categories (index action) there is an error:

undefined local variable or method `json' 

But in show action everything fine. All files has .jbuilder extension. Here is controller code:

def index   @categories = Category.all end  # GET /categories/1 # GET /categories/1.json def show   @category = Category.find(params[:id]) end 

Stack trace:

app/views/categories/index.json.builder:1:in_app_views_categories_index_json_builder___502133872307116590_70140532925300' actionpack (3.2.11) lib/action_view/template.rb:145:inblock in render'
activesupport (3.2.11) lib/active_support/notifications.rb:125:in instrument'
actionpack (3.2.11) lib/action_view/template.rb:143:in
render'

like image 993
Meliborn Avatar asked Jan 24 '13 23:01

Meliborn


1 Answers

Try to rename your file index.json.builder to index.json.jbuilder

like image 186
wedy Avatar answered Sep 22 '22 00:09

wedy