-2

I just started studying Rails and I need some help.

I executed the command rails g scaffold posts title:string description:string, and I have generated some pages and a controller.

Page localhost:3000/posts shows me all my posts.

Page localhost:3000/posts/new give me the form to create a new post.

How could I create a post from localhost:3000/posts page? My code here - github

Thank you a lot!

  • The guides are a great first stop in your Rails journey https://guides.rubyonrails.org/getting_started.html – Eyeslandic Feb 19 '21 at 14:44

1 Answers1

1

When you access the page localhost:3000/posts, you basically are making a GET request to /posts route. To create a new element, you must make a POST request to the /posts route. So, you need to create a form using method POST, or use the javascript to make a background post request on the index.

On terminal, you can exec rails routes to check all the routes.

Jon Maciel
  • 106
  • 1
  • 3