NameError in PostsController # index | uninitialized constant PostsController :: Post

0

Galera, unwittingly my girlfriend moved the folders of my project in Ruby on Rails and started to make that mistake. What can I do? It looks like he's not recognizing the Post as a class ...

    
asked by anonymous 18.07.2017 / 23:31

2 answers

0

Make sure that the Post class is correctly set in the file app/models/post.rb file of your application and if it is implemented similar to:

class Post
  # código
end

Accidents do happen. One piece of advice I give you is to version your application code with a version control system such as Git ( link ). In this way, any accidental change or loss of code can be easily reversed.

    
19.07.2017 / 23:13
0

You did not import your Post model inside the Controller, so it can not identify the class.

class PostController < ApplicationController
  require 'models/post'

  def index
    @posts = Post.All
  end
end
    
19.08.2017 / 17:43