Lay out an ArgumentError throw in rails 3.1

In the Rails 3.1 application and the updated Devise 1.4.7, when I am at http: // localhost: 3000 / users / sign_up (as indicated in the rake routes), I get "ArgumentError in development / registration # new" extracted source "- line 3:

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

What is the solution to this? Thank you in advance.

 Deals::Application.routes.draw do devise_for :users root :to => "home#index" end 
+4
source share
3 answers

You have too many arguments. form_for needs only one argument (resource), for example:

 @registration = Registration.new form_for @registration 

And you can optionally pass :url if you need to.

0
source

Try it.

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

I can confirm that when I run rails generate devise:views and look at the default working template copied from the gem, in the application /views/dev/regations/new.html.erb, form_for is called by Devise with arguments:

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

If you prefer a link to copy gem views, view the views in the repo .

However, if you (or someone else reading this) try to use the registration form with your own controller, it is quite possible that you will need to recreate some of the methods from the Devise controller in order to get the form for rendering . Assuming you called your user class User :

 def resource_name :user end def resource @resource ||= User.new end def devise_mapping @devise_mapping ||= Devise.mappings[:user] end 
0
source

All Articles