Ruby on Rails Tutorial Part 6 - CRUD - Create - Save Method
Loading...
1,598
Loading...
Uploader Comments (andrewperk)
see all
Video Responses
This video is a response to Ruby on Rails Tutorial Part 5 - CRUD - Read - Find Method
see all
All Comments (9)
-
Once again, verry helpfull tutorial.
-
@traendone hi got the same problem as you while ago and discover my problem was
from
--redirect_to post_path, :notice => "Your post was save"-- i just added letter "s" on the path that will redirect to the index
-- redirect_to posts_path, :notice => "Your post was save"--
just share and not shoving my late answer :)
-
@andrewperk I even know why I put the equals sign there.
Thanks for the reply, patience, and videos.
-
@andrewperk Thankx a lot, btw Great tutorial :)
Loading...
traendone 2 months ago
@traendone Check your layout file where we looped through the flash hash. You may have put an equals sign in the ERB tag for the loop statement. You only use the equal sign when outputting, not in the actual loop statement or if/else etc... So you should only have an equal sign where we output the value of the loop. <% flash.each do |key, value| %>
andrewperk 2 months ago
@traendone Well youtube won't let me put in the actual code in this comment for some reason, so I tried to use html entities but that still didn't work. The point was to show you how it does not have an equals sign in the loop statement. Look again at the video where we loop through the flash hash in the layout to see it. Hopefully this helped you.
andrewperk 2 months ago
How is params[:post] working, you dint pass any parameter from html having :post as its name??
koolestdudenw7 2 months ago
@koolestdudenw7 When we pass in the @post object to the form_for helper in our view it uses the name of that object to create a hash. In our case the hash is named post. When we create the form fields for the title and content attributes these values are stored under that post hash as post[title] and post[content]. This post hash is available to us in the params hash under its symbol name :post, like so: params[:post]. It contains the data for title and content from the form.
andrewperk 2 months ago