Key :request_path not found

Hello! I am very new to Phoenix, but have already some tasks to do. Now I’m rewriting navigation bar from Phoenix to Phoenix Liveview and got some problems. For example, in the original file there were defined optional classes so active tab has class “active” (#{active_class?(@socket, "/")}).

I copied that code, but it doesn’t work. I get error “key :request_path not found”, even when assign :request_path to nil in a socket. Also it seems like navbar page doesn’t see any assigns I’ve done on my navbar_live.ex. What shall I do with that? All tutorials I found were not very helpful.

Really sorry if my question is quite silly, also so much grateful to everyone for answer

Sorry I have no idea, but you might get some help if you include the relevant parts of the stack trace, and your code that triggers this. It could be that that’s not even the code that’s generating it.

The error you’re getting sounds like the old code was calling active_class? with a Plug.Conn struct - @socket is going to be a Phoenix.LiveView.Socket which doesn’t have the same fields.

Re: not seeing updates - it’s hard to say without more detail of your application, but it could be a “root layout” vs “live layout” issue

Thank you for help! Honestly, I made so much mistakes there, but finally I solved them. The main issue was I couldn’t find right way to assign class “active” on button in navigation if current page matched it. Solved it with checking “if @socket,view == MyPageLive”, so that’s it :slightly_smiling_face: