this is probably a very basic question.
I have installed rails 3 and generated a project, after that i generated a model called post and a home index which routed root to. To get the latest posts listed on the home index page i moved the necessary methods from the posts controller to the index controller and also the necessary code into the index.html.erb file of home.
I have tried moving all the create and edit methods from the post controller and also the _form.html.erb from the post views to try and print the post form on my index page using render ‘form’.
But i get this error:
“undefined method `model_name’ for NilClass:Class”
How can i solve this problem? Grateful for all help.
Maybe the @post variable used by your form is not defined.
If you have moved your form in your index, verify that in the index action, you create both the @post and the @posts variable like this :