I want to allow the user and nonlogin visitors to create posts, but have trouble in coding
In ruby on rails tutorial, I find:
@post =current_user.posts.build(params[:post])
But the curren_user would be nil.
Another approach is
@post.user = current_user
This seems ok
but is this line too ugly? should I need to create a guest user to put those posts into it?
I want to allow the user and nonlogin visitors to create posts, but have
Share
You could do this, assuming you are using devise:
application_controller.rb