Ask A Question

Notifications

You’re not receiving notifications from this thread.

Edit & Update Blog Post Actions Discussion

Question: when i removed "blog_posts" from my routes, turning our routes

get "/blog_posts/new", to: "blog_posts#new", as: :new_blog_post
get "/blog_posts/:id/edit", to: "blog_posts#edit", as: :edit_blog_post
get "/blog_posts/:id", to: "blog_posts#show", as: :blog_post
post "/blog_posts", to: "blog_posts#create", as: :blog_posts
root "blog_posts#index"

into

get "/new", to: "blog_posts#new", as: :new_blog_post
get "/:id/edit", to: "blog_posts#edit", as: :edit_blog_post
get "/:id", to: "blog_posts#show", as: :blog_post
post "/", to: "blog_posts#create", as: :blog_posts
root "blog_posts#index"

I would receive

undefined method `blog_posts_path' for #ActionView::Base:0x000000000378e8

when visiting /:id/edit and /new.

Does this have something to do with "create" being mapped to the same route as root?

Reply

hey, great video again.
but i had one thing i had little hard time understanding. it was the "blog_post_params" method.
i thought it was just filtering and did not quite understand how it works. it turns out params.require(:blog_post) gets the blog_post itself. I was thinking it as a filter.

But it turns out it finds the object and makes it it's root object. And then .permit part makes the actual "filtering".
You kinda explained this quickly on your previous videos but actually understanding that part is really important to understand this video. Maybe you can mention it somewhere again.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.