“form_for @ecard"和“form_for :ecard"有什么区别? [英] What is the difference between 'form_for @ecard' and 'form_for :ecard'?

查看:67
本文介绍了“form_for @ecard"和“form_for :ecard"有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个带有所有正确操作和视图的 restfull 控制器.它目前与 new_html.erb 视图完美配合,该视图使用包含如下结构的 form_for:

I implemented a restfull controller with all the correct actions and views. It works currently perfectly with a new_html.erb view that uses a form_for containing a structure like:

<% form_for @ecard do |f| %> 

在看一些教程时,我看到人们也使用这种结构:

when watching some tutorials i saw that people also use the structure:

<% form_for :ecard do |f| %>

这听起来合乎逻辑..但是当我尝试使用 <% form_for 时:ecard do |f|%> 结果帖子转到不同的操作,然后使用 <% form_for @ecard do |f|%>..

It sounds logical.. but when i try to use the <% form_for :ecard do |f| %> the resulting post goes to a different action then using <% form_for @ecard do |f| %>..

推荐答案

Marco,

这之前已经在网站上回答过:

This has been answered on the site before:

实例变量与 ruby​​ on rails 中的符号 (form_for)

我希望能解决这个问题.

I hope that clears it up.

这篇关于“form_for @ecard"和“form_for :ecard"有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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