开发者

what's the difference between create and new?

开发者 https://www.devze.com 2023-01-30 14:26 出处:网络
I did: resources :posts What\'s the difference between the \'create\' and the \'new\' urls?开发者_运维百科In the Rails convention new is used with the HTTP verb GET and create is used with POST.

I did:

resources :posts

What's the difference between the 'create' and the 'new' urls?开发者_运维百科


In the Rails convention new is used with the HTTP verb GET and create is used with POST.

Say you are creating a blog and you have a model object called post. In the controller the new method will send a new post object to the view (a form). When the user fills out the form in the view and clicks submit, the form will POST the data to the controller's create method where it will be saved.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号