Hey guys. I was following a guide online to start my first blog in Rails. However, it appears that the instance variables are not working in my code, almost as if Sublime Text is not interpreting it the right way. I’m using Rails 5.02, Ruby 2.4.0, and I have done all of the updates on a MacBook i7/16 GB unit. Any ideas ? In my Controllers folder specifically,
def new
@post = Post.new
End.
You see @post should be highlighted in red, but instead it is white and when I run the Rails server It doesn’t show up properly when I go to the web.
Here is my posts_controller.rb file:
class PostsController < ApplicationController
def index
@posts = Post.all
end
def new
@post = Post.new
end
def create
@post = Post.new(post_params)
if @post.save
redirect_to @post
else
render 'new'
end
end
def show
@post = Post.find(params[:id])
end
private
def post_params
params.require(:post).permit(:title, :body)
end
end
Anything with @ symbol before it is not being read. Do I have to do something to activate this ?