Doesn't show “can't be blank”
I have field to input data of post
<%= simple_form_for @post, remote: true do |f| %>
<%= f.error_notification %>
<%= f.input :title %>
<%= f.button :submit %>
<% end %>
In model I have validation_presence_of :title, but when I confirm button without filling title it doesn't create new object. But why it just doesn't show that title can't be blank?
My new and create in controller:
def new
@post = Post.new
end
def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to :back, notice: 'Post was successfully created.' }
format.js
else
format.html { redirect_to :back }
format.js
end
end
end
private:
def post_params
params.require(:post).permit(:title)
end
コメント