Rails:设计覆盖创建方法和渲染错误

时间:2012-04-14 08:52:34

标签: ruby-on-rails-3 forms devise fancybox registration

我是rails的新手,开发第一个应用程序变得很难,因为你知道事情,但你不知道怎么做。

我将注册表单设置在一个框中,它使用“fancy-box”jquery弹出窗口。 当某些用户无法注册时,我希望页面保留在包含的页面中,并显示验证错误, 当他正确注册时,我想在主页中重定向他,但我不能这样做:

我的控制器覆盖了设计方法:

def setup
  @society = Society.new
end

# GET /resource/sign_up
def new
  super
end

# POST /resource
def create
  build_resource

  if resource.save
   if resource.active_for_authentication?
      set_flash_message :notice, :signed_up if is_navigational_format?
      sign_in(resource_name, resource)
      respond_with resource, :location => after_sign_up_path_for(resource)
    else
      set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
      expire_session_data_after_sign_in!
     respond_with resource, :location => after_inactive_sign_up_path_for(resource)
    end
  else
    clean_up_passwords resource
    render action: new  
  end
end

protected

def after_sign_up_path_for(resource)
  '/vetrina/index'  #my homepage
end

和表格:

<%= simple_form_for @society, :html => { :class => 'form-horizontal' } do |f| %>
  <fieldset>

  #all the inputs are here

  <div class="form-actions">
    <%= f.submit nil, :class => 'btn btn-primary' %>
    <%= link_to 'Cancel', "#", :class => 'btn' %>
  </div>
</fieldset>
   

任何帮助?

0 个答案:

没有答案