Use has_secure_password to build an authentication system for your application. Make sure to use the helper methods to selectively hide elements on the template when logged in/not logged in (eg, the create post form, etc), and use before filter to prevent unauthenticated users from accessing certain controller actions (eg, create post action, etc). Also now assign the user to the current_user when creating new posts or comments. Fix any data integrity issues from the paste, like missing user_id values in the foreign key columns.