User
has_one UserProfile
。
次に、列を文字列として UserProfile
持ちます。wanted_message
wanted_message
ここでは、特定のユーザーがメッセージを入力して「更新」ボタンを押すと、更新する入力ボックスを表示しています。
どうやって?今、「更新」を押すと、URL「/users/12」に移動します
私はそれを望んでいません:(ページをロードせずに更新したい(Ajaxリクエスト)。
次にupdate_message
、ユーザーコントローラーでアクションを呼び出したい
どうやって?
<%= form_for(current_user, :url => {:controller => "user", :action => "update_message" }, :remote => true, :class => 'form-search') do |f| %>
<%= f.fields_for :user_profile do |profile_form| %>
<div class="input-append">
<%= profile_form.text_field :wanted_message, :class => 'span6' %>
<button type="submit" class="btn">Update</button>
</div>
<% end %>
<% end %>