V
V
Vitaly Liber2015-07-03 16:29:53
Ruby on Rails
Vitaly Liber, 2015-07-03 16:29:53

How to find out by path in rails where views are?

There is a piece of code that is responsible for displaying four random products from the database.
<%= products_from_same_category(@product) %>
The code is in views/products/show
How do I know where it gets views from?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsuhachev, 2015-07-03
@VitalyLiber

products_from_same_category is a function (most likely in helpers somewhere), read it and see where it takes templates from.

V
Viktor Vsk, 2015-07-03
@viktorvsk

In the variable $LOAD_PATH- all the paths where the code can come from.
First, it looks to see if there is a template in your application, after that it goes through the gems in the order they are connected (the last one is decisive, unlike the situation with the router)
Or put byebug/binding.pry in view and see what's in__FILE__

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question