2011-10-04 37 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