Steps:
- mix phx.new blog
- check DB username, password and other settings
- mix ecto.create
- iex -S mix phx.server
- to test if everything is working fine for now
- check by typing "localhost:4000" in browser
- mix phx.gen.auth Accounts User users
- to create user authentication
- mix deps.get
- mix ecto.migrate
- mix test
- make sure there is a postgres superuser account in the postgres installation
- homebrew might now have it as default
- mix phx.gen.live Stories Story stories title:string body:text user_id:references:users
- copy the routes from the terminal into the authentication routes in router.ex
- add "setup :register_and_log_in_user" in story_live_test.exs Adding user_id into the DB story entries
- add the user_id into the live component in index.html.heex
- user_id = {@current_user.id}
- add user_id in the story.ex changeset for ecto
- map user_id into the story_params
- Enforce Authencation
- created new def with added variables in list_stories within story.ex in blog
- created new getstory! within story.ex in blog
- added a variable when mounting in story_live/index.ex
- added a variable when editing and deleting in story_live/index.ex
- Copy the index.ex and index.html.heex from story_live folder to paste inside story_live folder
- Change the copied index.ex and index.html.heex to home.ex and home.html.heex
- Change the home route in router.ex to a live end point - StoryLive.home
- Modify home.ex to get all stories without parameters
- Modify home.ex to :home instead of :index
- Modify home.html.heex to remove unnecessary buttons
- Disable show/edit in router.ex
- Clean up show.html.heex in story_live to disable editing modal
- Add navigation to root.html.heeex in layouts
- Move the show endpoint to the public route in router.ex
- Ensure that this line is after the authencated new story line so that there is no error
- add the field name in blog>accounts>user.ex
- mix ecto.gen.migration add_name
- alter (not create) the user table and add the field name in the migration file
- update blog>accounts>user.ex in the registration_changeset to include the name parameter
- Go to blog_web>live>user_registration_live to include name field
- Associate user table to stories table by modifying blog>stories>story.ex by changing field to belongs_to
- Modify blog_web>live>home.html.heex to display user name
- Add preload into stories.ex so that users are loaded when listing stories
- OPTIONAL: clean up database
- mix ecto.drop
- mix ecto.create
- mix ecto.migrate
- Add preload into stories.ex so that we can see the name when we get(read) a story
- mix phx.gen.live Comments Comment comments message:text story_id:references:stories
- mix ecto.migrate
- OPTIONAL: create the test.ex and test.html.heex to demo heex in heex in comment_live
- Add test.html.heex into show.html.heex in story_live by using the correct html tag
- steal the form component from comment index and put into story_live show.ex
- mount comment in show.ex using a comment struct
- edit the comment form in show.ex to allow only new comments
- i.e. no need for edit
- assosciate comment to stories
- add story.id into the form component in show.ex
- add the field for story.id in the comment form_component
- make sure the value is written (@story_id)
- change the story_id field and changeset in comment.ex
- add has_many to stories so that there is a resolution for the deletion of stories for comments
- Optional: Creating an index page for users
- create the def list_accounts using Repo all in accounts.ex
- create the folder account_live folder in blog_web/live
- create the index.ex and the index.html.heex
- enhance show.ex in stories to show comments
- add list of comments
- preload the comments in stories in stories.ex
- associate comments to users
- add belongs_to :user in comment.ex
- mix ecto.gen.migration comment_has_user
- mix ecto.migrate
- Only users can comment, so add the if statement in show.html.heex
- Preload users who made the comments in stories
- Allow anonymous comments by using conditional statements when mounting
- Ensure that the variables are passed between show.ex and show.html.heex
- Copy and paste tailwind templates into the html.heex file
- Pass tests (not really, fails story_id validation in the comment tests)
- End
user and user passwords [email protected] - testtesttest