Rails:“新"功能如何实现?称为“创建"的动作行动? [英] Rails : How does "new" action called "create" action?

查看:76
本文介绍了Rails:“新"功能如何实现?称为“创建"的动作行动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照本教程 http://guides.rubyonrails.org/v3.2.13 /getting_started.html 来构建3.2.13版的Rails应用.如果转到第6.9节,将找到控制器并查看用于创建新帖子的视图.在这里,我不了解如何将@post变量从new动作传递到create动作,以及create函数在哪里被调用?另外,在处理edit和更新actions时,我遇到了相同的问题.请通过这个指导我.

I am following this tutorial http://guides.rubyonrails.org/v3.2.13/getting_started.html to build my rails app in version 3.2.13 . If you go to the section 6.9 you will find controller and view for creating new posts . Here I do not get how @post variable is passed from new action to create action and where is create function called ? Also , I faced the same problem while working on edit and update actions . Please guide me through this .

推荐答案

它没有传递给create动作,而是使用从new动作显示的表单中传递的参数再次实例化.

It's not passed to create action, it's instantiated again with params you pass from the form displayed with new action.

create操作通过POST请求调用到config/routes.rb中指定的路径,从而导致特定的控制器和操作.

create action is called with POST request to the path specified in config/routes.rb, leading to specific controller and action.

这篇关于Rails:“新"功能如何实现?称为“创建"的动作行动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆