The Params Hash | GoRails
Nice video - thanks. Request for future episode: part 2 on params, explaining stuff like:
params.require(:blog).permit(:title, :body)
How that all works, what Rails does when required params are missing, or not permitted params are passed through etc.
Definitely an episode on strong_params in the works. This is a great one to go in depth on.
It would be better to use larger font size in vim/macvim/terminal when recording a screencast.
Ah, Thank you for this video! Just started with rails, and this was just great. I'll continue to watch the rest :)
Great explanation. I learned a lot and many things has become clear but I still don't understand how rails app knows if it is a Post or a Get or other URL. And other thing which is still not clear is what is "form tag blog_path" and why is it blog_path and even why do we need it at all.
Really good question and one I am going to cover in more depth in some future episodes. Basically blog_path is a Ruby method that returns a URL from your routes file. The path it returns looks like "/blog". The reason you need that is that when you submit a form, you need to pass it a URL that accepts the form data so it can save it to the database. Usually that's a specific url dedicated to just saving data. For example, if you open up the HTML on the login form on GoRails, you'll see that it points to /users/sign_in as the action which knows how to take your username and password, validate it, and sign you in:
<form class="new_user" id="new_user" action="/users/sign_in" accept-charset="UTF-8" method="post">
Yes! Thank you for this. I have a lack of knowledge in how certain aspects of rails works. This was one part I didn't understand and now it clicked. If I don't know how important things work, I just can't progress and I feel like i'm stuck. I feel most tutorials gloss over this completely and after watching this and going over the rails docs, I actually understand how it works. Thanks Again!
You're welcome! Let me know if you have any suggestions on other topics like this you'd like to hear explained. it's easy for me to take these things for granted these days so ideas for topics are always welcome!