Giter Club home page Giter Club logo

Comments (7)

SophieDeBenedetto avatar SophieDeBenedetto commented on June 20, 2024 1

If I recall correctly the tutorial branch has the starting state of the code for the blog post walk-through. Per this line from the blog post:

The starting state of the tutorial branch includes the chat domain model, routes, controller and the initial state of the LiveView, described below

You will find some completed code in the tutorial branch that takes care of the initial state of the app for the blog post. Then, the blog post walks you through adding additional features.

from live-view-chat.

SophieDeBenedetto avatar SophieDeBenedetto commented on June 20, 2024

Hi @idkjs! You should be able to create a user through the browser like this:

  • start the server with mix phx.server
  • Visit the /users/new route
  • Fill out the registration form and sign up!

from live-view-chat.

idkjs avatar idkjs commented on June 20, 2024

Tried that. I get a browser error asking me to run migrations which doesn't work. I am afk and will try to get you a better error ASAP. Thank you.

from live-view-chat.

idkjs avatar idkjs commented on June 20, 2024

@SophieDeBenedetto thank you. That helped and I see it was mentioned in #1 .

The readme says that the seed should have created some chats and users though it seems like it doesnt do anything.

This is the seed file:

# Script for populating the database. You can run it as:
#
#     mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
#     Chat.Repo.insert!(%Chat.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.

Here is the chats link in the browser.

Screen Shot 2020-11-04 at 12 40 09 PM

I feel like i'm missing something since the code in tutorial branch doesnt seem to match what is in the tutorial. Am I missing something?

Thanks again for taking the time to teach.

Here is the terminal history if it helps: https://gist.github.com/idkjs/7ad9ecf509e3fa1933976a7e6270cea9

from live-view-chat.

SophieDeBenedetto avatar SophieDeBenedetto commented on June 20, 2024

Hi again! You need to checkout the tutorial branch and work off of that. You can see that the seed file in the tutorial branch is populated https://github.com/elixirschool/live-view-chat/blob/tutorial/priv/repo/seeds.exs

from live-view-chat.

idkjs avatar idkjs commented on June 20, 2024

Thanks. I kinda gave up on the tutorial branch because I didnt understand what we were supposed to be following along with. Is the tutorial branch a start position?

For example, the first step in the blog is

# lib/phat_web/controllers/chat_controller.ex

defmodule PhatWeb.ChatController do
  use PhatWeb, :controller
  alias Phat.Chats
  alias Phoenix.LiveView
  alias PhatWeb.ChatLiveView

  def show(conn, %{"id" => chat_id}) do
    chat = Chats.get_chat(chat_id)

    LiveView.Controller.live_render(
      conn,
      ChatLiveView,
      session: %{chat: chat, current_user: conn.assigns.current_user}
    )
  end
end

Then I see in the tutorial branch, that file has the following content:

defmodule PhatWeb.ChatController do
use PhatWeb, :controller
alias Phat.Chats
alias Phoenix.LiveView
alias PhatWeb.ChatLiveView
plug :authenticate_user
def index(conn, _params) do
chats = Chats.list_chats()
render(conn, "index.html", chats: chats)
end
def show(conn, %{"id" => chat_id}) do
chat = Chats.get_chat(chat_id)
LiveView.Controller.live_render(
conn,
ChatLiveView,
session: %{chat: chat, current_user: conn.assigns.current_user}
)
end
defp authenticate_user(conn, _) do
case get_session(conn, :user_id) do
nil ->
conn
|> Phoenix.Controller.put_flash(:error, "Login required")
|> Phoenix.Controller.redirect(to: "/sessions/new")
|> halt()
user_id ->
assign(conn, :current_user, Phat.Accounts.get_user(user_id))
end
end
end

So it looks its already been done or this has more code in it then your blog? Idk. What are we supposed to do here if we are following along.

Probably me. Any guidance would be appreciated. Thank you.

from live-view-chat.

idkjs avatar idkjs commented on June 20, 2024

Ok. Thank you. Given my inexperience with elixir, I did not know what to make of that line. I saw it but was guessing as to what exactly it affected. I will look at it again and try to think through more carefully. Thank you for taking the time, @SophieDeBenedetto .

from live-view-chat.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.