2
votes

I have this error in Rails 4.1.4, but I can't see where should be the problem: syntax error, unexpected end-of-input, expecting keyword_end

class PostsController < ApplicationController
  def index
    @posts = Post.all
  end

  def show
    @post = Post.find(params[:id])
  end

  def new
    @post = Post.new
  end

  def create
    @post= Post.new(post_params)
    if @post.save
      redirect_to posts_path
    else
      render "new"
    end
  end

  def edit
  end

  def update
  end

  def destroy
  end

  private
  def post_params
    params.require(:post).permit(:title, :content)
  end
end
2
looks ok... can you please post the stack trace.Hardik
for which action you got that error?Emu
it may be the problem in your view , you can check view file alsoDeepti Kakade
in browser i have marked last endpictonica
I do not see any error: i can just add this file to my project and it parses correctly.nathanvda

2 Answers

1
votes

Try adding this in new method

Post.new(params[:post].permit(:title, :content)

and remove that private method

0
votes

The Problem i see with is with where you declared the private method, you did not indent the post_params method properly and the private method has no "end"

Do this instead..

private
 def post_params
  params.require(:post).permit(:title, :content)
 end
end