Layouts

Hi guys, can someone tell me why I can’t use routes like “user_path” in custom layouts like ‘user-layout.html.erb’ ???

Thanks & regards.

does the route exist? what is the error you get?

try rake routes to see if user_path exists.

Yes, I’m trying all the routes and no one works. It says ‘cannot find user_path’. These are the routes that I have.

user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy

In the application.layout those routes are working, I have to specify any special route tu use a different layout?.

Thanks

it’s users_path

No. In case that would be the problem I could use any other route but that is not the case. I cannot use any other route in the custom layout…

How exactly are you trying to use the routes? Do you have some code you could share?

Yes sure.
’layouts/user-layout.html.erb’

<%= link_to 'Log out', user_path , method: :delete %>

I have a few more layouts and it does not work neither. But it does in ‘application.html.erb’. I think that some route configuration have to be set before this but I don´t know what.

Thanks

I would use “pry” for this case.
“binding.pry” in user-layout.html.erb and find out what is the
problem

I don’t know what exactly is that… But have to be an easier way to fix this.

Ok I don´t know what I did but now it works… :frowning: so sorry

Using a debugger is sometimes the right way to find problems. Learn
how to use it and you will save a lot of time in the long run.

Colin

Ok, I will take a look on it. Thanks.

Could you please take a look at my other post related with Ajax functionality please?.

Thanks & regards.

Alfredo.

Hi guys
Firstly rake routes on console , check existing path is available. Not available then need define path in route file

Hi guys
I have problem when i try to link to my new page, can any one help me.

thanks and regard.

get “link/home”
get “link/about”

Hi guys
I have problem when i try to link to my new page, can any one help me.

thanks and regard.

get "link/home"
  get "link/about"

Probably someone will help if you describe the problem. Also I am not
sure what this has to do with the subject of the thread (Layouts). If
it is not a follow on from the previous post please start a new
thread.

Colin