Ok, been staring at this for two hours now.
I’m experimenting with an empty form in HAML in views/categories/index.html.haml
=form_for @categories do |f|
=f.submit
my categories_controller.rb looks like…
class CategoriesController < ApplicationController
# GET /categories
# GET /categories.json
def index
@categories = Category.all
respond_to do |format|
format.html # index.html.haml
format.json { render json: @categories }
end
end
end
I’m getting… NoMethodError in Categories#index
undefined method `model_name’ for NilClass:Class
I know this is easy but my mind is mush right now.
You have to use
form_formethod for a specific model, not for an array of them, like:And your error seems like is showing you that you don’t have any records in your categories table. Otherwise the complain would have been different 🙂