2010-11-16 55 views
0

我不断收到这个错误,当我尝试并查看我的注册用户页面轨,倾斜视图注册用户页面

的Firefox已检测到服务器 被重定向此 地址的请求的方式,将从来没有 完整。

def register 
    #User registration form 
    @user = User.new(params[:user]) 
    if @user.save 
     flash[:notice] = "Account Created Successfully" 
     redirect_to(:action=>'menu') 
    else 
     flash[:notice] = "Please fill in all fields" 
     redirect_to(:action=>'register') 
    end 
    end 


<div class="user new"> 
    <h2>Create User</h2> 

    <%= form_for(:user, :url => {:action => 'register'}) do |f| %> 

    <table summary="User form fields"> 
     <tr> 
     <th>First Name</th> 
     <td><%= f.text_field(:first_name) %></td> 
     </tr> 
     <tr> 
     <tr> 
     <th>Last Name</th> 
     <td><%= f.text_field(:last_name) %></td> 
     </tr> 
     <tr> 
     <th>UserName</th> 
     <td><%= f.text_field(:user_name) %></td> 
     </tr> 
     <tr> 
     <th>Password</th> 
     <td><%= f.text_field(:password) %></td> 
     </tr> 
     <tr> 
     <tr> 
     <th>Email</th> 
     <td><%= f.text_field(:email) %></td> 
     </tr> 
     <tr> 
     <tr> 
     <th>Telephone</th> 
     <td><%= f.text_field(:telephone) %></td> 
     </tr> 
     <tr> 
     <td>&nbsp;</td> 
     <td><%= submit_tag("Register") %></td> 
     </tr> 
    </table> 


    <% end %> 
</div> 

回答

1

难道你不在你的视图方法中重定向?

redirect_to(:action=>'register') 

你是否区分视图方法和用户提交表单时实际触发的方法?防爆。对于RestfulAuthentication而言,该视图称为“新建”,并且在提交表单后创建用户的实际方法称为“创建”。

0

我认为火狐消息意味着你有某种服务器重定向循环的事情。例如,如果您的应用程序控制器中有一个之前的过滤器,说明如果用户未登录,则将其发送到注册用户页面。但是,在重定向到注册页面后,该用户仍未登录。然后,Rails将尝试将它们重新导向到该页面。从而形成一个循环。

1

您正在重定向您在else中的相同注册表操作。尝试render :action => '<action that contains the form>'

+0

另外,equals('<%=')在'form_for'中不需要。只要做'<%'。 – Todd 2010-11-17 00:27:59