2010-10-08 18 views
9

Mam dość prosty Rails Zdalny formularz w haml w częściowym pod wspólną/użytkowników:Rails 3: Metoda niezdefiniowana `remote_form_for”

- remote_form_for :user, :url => { :controller => "users", :action => "create" } do |f| 
    .field 
    = f.label :name, t('name') 
    = f.text_field :name 
    .field 
    = f.label :email, t('email') 
    = f.text_field :email 
    .actions 
    = f.submit 

Bez względu na to jak bardzo mi bawić się z nim, to po prostu nie będzie praca. Zawsze mam następujący błąd:

undefined method `remote_form_for' for #<#<Class:0x1036e8e40>:0x1036dfd90> 

Czy robię coś głupiego? Działa doskonale z form_for.

Odpowiedz

1

To dlatego ta metoda jest usunięcie on Rails 3

teraz używać

form_for ..., :remote => true 

Kod staje:

- form_for :user, :url => { :controller => "users", :action => "create" }, :remote => true do |f| 
    .field 
    = f.label :name, t('name') 
    = f.text_field :name 
    .field 
    = f.label :email, t('email') 
    = f.text_field :email 
    .actions 
    = f.submit 

i trzeba rails.jquery.js lub same w prototypie używać tego. To ulepszenie UJS w szynach.