Skip to main content

How do I update?

Rails • Asked by Royal Summers
So, I'm following a YouTube  video trying to create my first Blog.  See the following link, at minute  13:50, https://www.youtube.com/watch?v=YCJqAZ--Sd8.  I'm attempting to do an update with appears to be a form helper.  Here's my line of code: <%= form_for(post, url: url, local: true) do |form| %>  Can anyone tell me why might the Update isn't working?

I just tried it again and got the following message:

Started POST "/authors/posts" for 127.0.0.1 at 2018-05-15 07:34:57 -0700
Processing by Authors::PostsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"07t0mQxSuviikB9QfFsDLpGAAq13aARnnE7CFNH8L8QgYDJOPX0oSzQl39u8NgkIhorDrexoYfn/93rq1iQJ1Q==", "post"=>{"title"=>"Royal Post 2", "banner_image_url"=>"", "body"=>"test", "description"=>"test"}, "commit"=>"Create Post"}
   (0.0ms)  begin transaction
  Post Exists (15.0ms)  SELECT  1 AS one FROM "posts" WHERE ("posts"."id" IS NOT NULL) AND "posts"."slug" = ? LIMIT ?  [["slug", "royal-post-2"], ["LIMIT", 1]]
   (0.0ms)  rollback transaction
  Rendering authors/posts/new.html.erb within layouts/author
  Rendered authors/posts/_form.html.erb (6.0ms)
  Rendered authors/posts/new.html.erb within layouts/author (104.0ms)
  Rendered layouts/_navbar.html.erb (2.0ms)
Completed 200 OK in 1337ms (Views: 771.7ms | ActiveRecord: 15.0ms)

Appears that the post already exists?  I recently added Devise and before got the message that I can't post unless the author exists but the author exists and I am signed-in?  Any suggestions?

Haven't looked at the YT vid, but based on your log, are you on correct page? `Rendering authors/posts/new.html.erb`
Check `rails routes` for the correct url, should look something like `edit_post`.
A typical Rails url would look like: `posts/<post_id>/edit`. 

The error about "Author doesn't exist" might have to do that you don't properly assign the Author to the post on create.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.