开发者

rails 3 form remote

I am write:

<%= form_for(current_user, :remote => true) do %>
  <p>
    <%= label_开发者_如何学编程tag t("language") %>: 
    <%= select_tag "language", options_for_select([["Русский", "rus"], ["English", "eng"]]) %>
  </p>

  <p><%= submit_tag t "options.save" %></p>
<% end %>

Inspector: http://deeflow.com/changer/inspect.png

Content: http://deeflow.com/changer/content.png

But, value in db doesn't updated


<%= form_for(current_user, :remote => true) do |f| %>
  <p>
    <%= f.label :language, t("language") %>: 
    <%= f.select :language, options_for_select([["Русский", "rus"], ["English", "eng"]]) %>
  </p>

  <p><%= f.submit t "options.save" %></p>
<% end %>

Notice the variable |f| and change of label_tag, select_tag and submit_tag to f.label, f.select and f.submit

In rails form_for and corresponding form_buider object(|f|) are used to group values under a common key, which rails can understand. *_tag helpers are generally used to pass unrelated parameters.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜