Vyacheslav Loginov
Vyacheslav Loginov

Reputation: 3216

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

Upvotes: 0

Views: 559

Answers (1)

rubish
rubish

Reputation: 10907

<%= 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.

Upvotes: 1

Related Questions