2010-12-20 120 views
0

我知道如何让我的表单在提交后不会被删除?在提交后保留值

这是我用来填充选择列表中的行:

<% = select: search,: style, [[All, ""]] + Proyect.all (: group => "style",: order => "style"). collect {| a | [a. style a.estilo]}%> 

请帮我

在此先感谢

回答

1

耶。非常简单。

解决与添加到当前行如下因素参数:

{:selected=>params[:search][:style]} 

从而留下

<% = select: search,: style, [[All, ""]] + Proyect.all (: group => "style",: order => "style"). collect {| a | [a. style a.estilo]},{:selected=>params[:search][:style]}%> 

感谢反正

------------- ------附件---------

这是正确的,但我的解决方案,一半好解决方案,因为我有问题,我f参数仍未创建?

如何做这样的事情:

{: selected => params [: search] [: style] if params [: search] [: style]! = nil}%> 

是如下:

<% = select: search,: style, [[All, ""]] + Proyect.all (: group => "style",: order => "style"). collect {| a | [a. ]},{: a.estilo style selected => params [: search] [: style] if params [: search] [: style]! = nil}%> 

什么想法?

0

您需要设置选择的选项。这种情况下,第二届一个选择:

<%= options_for_select([['Lisbon', 1], ['Madrid', 2], ...], 2) %> 

的解释

here