Im trying to make so that if someone make a post without a title the post will get a default title.
I have tried this so far
controller
def create
@post = Post.create(post_params)
if @post.title.nil?
@post.update(:title => 'Unnamed')
else
# DO NOTHING
end
end
controller
def create
if params[:title].nil?
params[:title] == 'Unnamed'
@post = Post.create(post_params)
else
@post = Post.create(post_params)
end
end
But it dosen't work. Any ideas what im doing wrong? Thanks in advance.