开发者

Devise in Rails 3: form_for throws undefined local variable or method

I am using devise in a rails 3 app. I am giving some users the ability to r开发者_开发问答egister other users. These registrations will simply add a new record with id and email to the users table. My routes contain the standard devise items.

In my invitations controller:

def new
  @invitations = blah blah # creates a list of people already invited

  @user = User.new # for the person begin invited

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @invitations }
  end
end

The view has a list of people already invited and then a form to add a new user. I am using the code from the devise registration form. Perhaps i don't need to do this? The following line in new.html.erb creates an error:

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

The error:

undefined local variable or method `resource' for #<#<Class:0x103655be0>:0x1036537f0>

Thanks!


Did you inherit your registrations controller from Devise's registrations controller?


I got past this error with the following:

<% form_for :user, :url => create_invitation_invitations_path(@user) do |f| %>

We'll see if i run into other complications.

UPDATE: no complications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜