In this new task, we will add associations to the Post model for categorization and ensure that each post has an author.
Task 6
Let's incorporate the following functionalities into the application:
- Create an
Organization model with a name attribute. Migrate the database
and add an entry for a sample organization through the Rails console.
- Add a
User model with attributes name, email and password_digest. It
is recommended that candidates utilize the bcrypt gem for secure password
hashing. Additionally, include a foreign key referencing the Organization
model within the User model. So, every user should belong to an
organization.
- In the
Organization model, the name attribute should not be NULL. In the
User model, proper validations for name, email, password and
password_confirmation should be added.
- Create a Category model with a
name attribute. Each post can be associated with more than one category.
- Modify the
Post model by adding foreign keys that reference both the User
and Organization models. Additionally, the Post model should have an association with the Category model to allow each post to be linked to multiple categories. This will ensure that each post has an author, is associated with an organization, and can have various categories.
- Modify the post listing page to display the name of the author and the categories associated with each post card.
- Add a searchable select input for enabling the user to select the categories for the blog post.
- Add an item in the
NavBar to show the list of categories. Upon clicking this item, an additional sidebar should open, listing the categories. The sidebar should include an option to search for categories and to add new categories. When a category is clicked, only the posts with that particular category should be displayed. If no category is clicked, all posts should be displayed.
- Include the author's name and categories on the blog post page.