2011-10-04 58 views
4

在Rails 3.1的應用程序和更新的設計1.4.7,當我訪問http://localhost:3000/users/sign_up(如耙路線指示),我得到「引發ArgumentError在設計/註冊#新」提取的源是3線:制定扔在引發ArgumentError軌道3.1

<%= form_for(resource_name, resource, :url => registration_path(resource_name)) do |f| %>. 

這是什麼解決方案?先謝謝你。

Deals::Application.routes.draw do 
    devise_for :users 
    root :to => "home#index" 
end 

回答

0

你有太多的論據。 form_for只需要一個參數(資源),就像這樣:

@registration = Registration.new 
form_for @registration 

而且你可以選擇性地傳入:url如果您需要。

0

試試這個。

​​
0

我可以確認,當您運行rails generate devise:views,並期待從創業板複製到應用工作的默認模板內/視圖/設計/註冊/ new.html.erbform_for被稱爲通過與設計參數:

form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| 

如果您希望複製創業板的意見參考,請查閱the views in the repo

但是,如果您(或其他人在閱讀本文)嘗試在您自己的控制器中使用註冊表單,則完全有可能您需要重新創建from the Devise controller中的某些方法,以便get the form to render。假設你叫你的用戶類User

def resource_name 
    :user 
end 

def resource 
    @resource ||= User.new 
end 

def devise_mapping 
    @devise_mapping ||= Devise.mappings[:user] 
end