Ask A Question


You’re not receiving notifications from this thread.

How do I update?

Royal Summers asked in Rails
So, I'm following a YouTube  video trying to create my first Blog.  See the following link, at minute  13:50,  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 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.
Join the discussion
Create an account Log in

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

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

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