# Programming Phoenix LiveView: B3.0 (page 27)

**URL:** <https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-page-27/8909>\
**Category:** PragProg Customers\
**Tags:** book-programming-phoenix-liveview, question\
**Created:** [19 April 2021 16:16 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-page-27/8909 "2021-04-19T16:16:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chrichton](https://forum.devtalk.com/user_avatar/forum.devtalk.com/chrichton/32/2724_2.png) [@Chrichton](https://forum.devtalk.com/u/Chrichton)\
**Post date:** [19 April 2021 16:16 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-page-27/8909/1 "2021-04-19T16:16:23Z")

</div>

I tried to do the exercise for the basic LiveView “game”.

One part is:  
Show a restart message and button when the user wins. Hint: you might want to check out the live\_patch/28 function to help you build that button

Several things were not clear to me:

- Should the success message and the Restart-Button be displayed in a new LiveView (CorrectLiveVive) or should I use the existing LiveView (WrongLiveView)?

I decided to use the existing LiveView.  
As I had to conditionally render the view for the success-case and the wrong-case,  
I added another state (answer\_guessed Boolean) to the socket.

This allowed me to use this state to conditionally include the “live\_patch”-method inside the render-function for the success case.

I then realized, I had to implement the “handle\_params”-method correctly.

See: [pento/wrong\_live.ex at master · Chrichton/pento · GitHub](https://github.com/Chrichton/pento/blob/master/lib/pento_web/live/wrong_live.ex)

I am asking: Is there an easier way to solve this exercise?

Thank you for your reply, Heiko

---

<div class="post-metadata">

**Author:** ![SophieDeBenedetto](https://forum.devtalk.com/user_avatar/forum.devtalk.com/sophiedebenedetto/32/2521_2.png) [@SophieDeBenedetto](https://forum.devtalk.com/u/SophieDeBenedetto)\
**Post date:** [19 April 2021 16:40 UTC](https://forum.devtalk.com/t/programming-phoenix-liveview-b3-0-page-27/8909/3 "2021-04-19T16:40:59Z")

</div>

Hi @Chrichton! Your approach looks pretty clean to me. There was one small error to fix though, your “guess” route definition in `router.exs` was missing the `/` before the word “guess”.

You’re right that if you use `live_patch/2` you’ll need to implement a `handle_params` function, and a later chapter will go into all the details there 🙂
