Lesson 6 — KanbanFlow: domain, Tailwind, and first views
This is the payoff lesson. We scaffold the KanbanFlow domain, apply Tailwind styling to Phlex::UI, and build the first real views.
The domain
KanbanFlow has five models. Generate them in this order so references resolve correctly:
|
|
Note: We’re creating a minimal
Usermodel here with justname. Authentication — login, logout, password handling, sessions — is covered in Module 10. For nowUseris a plain ActiveRecord model that gives our associations the correct shape.
Add associations and validations to each model:
|
|
|
|
|
|
|
|
|
|
Note the distinction between board.user and board.members:
board.user— the owner who created the boardboard.members— everyone with access including the owner, via memberships
This is a deliberate design — ownership and membership are separate concepts. A board has one owner but can have many members. In Module 10 we use this distinction to implement access control.
Seed data
With the models in place, add some seed data so every subsequent lesson has realistic content to work with:
|
|
Run it:
|
|
Verify in the console:
|
|
Restyling Phlex::UI with Tailwind
The component structure from Module 3 is unchanged. We only update the class strings. Here is Components::Button as an example — compare with the Pico version:
|
|
Rather than restyling each component manually — which is mechanical work that teaches nothing new about Phlex — download the pre-styled components and drop them into app/components/. The prop declarations, slot methods, and view_template structure are identical to Module 3. Only the Tailwind class strings have changed.
Download phlex-ui-tailwind.zip
Copy the contents into your Rails app, run the tests to confirm everything is working.
|
|
This is a good point to finish off Module 04. We have a basic structure in place that we can build on. Coming up in Module 05 we will investigate Tailwind in more detail and start to create some more complex views.