轨道形式的自定义URL路由

时间:2014-04-20 09:06:29

标签: ruby-on-rails forms devise

我是rails的新手,我想知道如何让用户在提交此表单时转到特定的url路径,而不是重新定向回主页,这是默认操作。我也在使用设计,但我不确定是否会改变任何东西(就像我说我很新!)。我尝试在提交按钮周围添加标签并更改顶部的form_for但无济于事。提前谢谢!

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


  <div id="title">
    <p class="main-titles"><a href="/">The 100 Story Project</a></p>
  </div>

  <div id="nav">

    <div class="register_fields">
        <%= f.email_field :email, autofocus: true, :placeholder => "Email Address" %></div>

    <div class="register_fields">
        <%= f.password_field :password, autocomplete: "off", :placeholder => "Password" %></div>

    <div class="submit"><%= f.submit "→" %></div>

  </div>

  <div id="written" class="sticky">
    <div class="main-titles written-margin"><p>Written by</p><p class="written-name"></p></div>
  </div>

  <div id="yellow">
  </div>

  <div id="background">
    <div id="story-wrapper">
      <p></p>
    </div>

  </div>
<% end %>

<%= render "devise/shared/links" %>

1 个答案:

答案 0 :(得分:0)

您将能够使用设计built-in helpers来实现此目标:

#app/controllers/application_controller.rb
Class ApplicationController < ActionController::Base
    def after_sign_in_path_for(resource)
       current_user_path
    end

    def after_sign_out_path_for(resource_or_scope)
       request.referrer
    end
end