Answer the question
In order to leave comments, you need to log in
How to get page data?
Hello! I don't understand how it works.
In many projects, for example, to get the page title, page content and any other data, they write like this:
@page.title
@page.content
@title = sql...
@page.title
Answer the question
In order to leave comments, you need to log in
The controller exists for that, to receive data and only after that give it to the view-part. In practice, you can do something like this in the view:
That is, in fact, execute a query to find the desired object directly from the view layer. But this is fu and a sign of complete ignorance (at least because views are not intended for this). Therefore, take for granted the need to receive data in the controller action, assign it to instance variables, and access instance variables in views.
In general, read from cover to cover rusrails.ru , sections "Models", "Views" and "Controllers".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question