Hey there y'all!
I know. The title sucks. Turn around and see who cares. Send money for PS5 tho. TQ!
As mentioned in the very beginning, Controllers handle the logic of data and its handling between the backend and the frontend.
By running the scaffold command Rails would have already created a controller for the model Post.
If you can open,
app/controllers/posts_controller.rb
You can see an auto-generated class with methods like index, new, create, show, edit, update and destroy.
Open and check the folder,
app/views/posts
You can see a few auto-generated html files named index, new, edit and show with the extension:
*.html.erb
ERB is a template that enables you to execute Ruby code inside html document. To embed Ruby code inside HTML we use the syntax:
<%= ruby_code_here %> or <% ruby_code_here %>
# '=' -> only the code that follows the equal sign is rendered on the webpage
As you'd have guessed earlier, the names of the views files corresponds to the name of the method(also called as action) inside the controller:
- index -> index
- new -> new
- edit -> edit
- show -> show
That's all for today. Gotta go cry thinking about my life. Jk. Gratitude be the only way.
Love,
M.
liked_the_post == true ? comment and share : comment and share