2021 ROR Flashcards
What is a scope in ROR?
Scopes are custom queries that you define inside your Rails models with the scope method.
in Post model:
scope :free, -> {where(premium: false)}
In Post controller:
@posts = Post.free
Why use scopes in ROR?
Scopes helps you avoid errors when your scope returns nothing.
<div>
</div>
<pre>
<code>
Scopes are used for exactly one thing, <br></br>
so you know what you get the moment you see one
</code></pre>
What does the error “Uninitialized Constant” mean?
It probably means that there is a file missing
What are the naming conventions for controllers?
The naming convention for controllers is Plural
example
EventsController, BookingsController etc
How do you add a favicon to an rails app?
in layout.html.erb and inside the head tag add:
And the image in the assets/images folder