Ruby on rails 使用轨道中的装置更换路线
我使用的是rails 4.1.1 我希望用户遵循的过程是使用基本设计表单注册,这样就可以使用电子邮件、密码和密码确认。当用户提交此文件时,我希望他们直接进入编辑配置文件页面。新用户注册页面的底部如下。我尝试了一些事情,但每件事都让我犯错误。任何帮助都将不胜感激!我还包括了我的设计链接,因为我认为这是我应该寻找的地方Ruby on rails 使用轨道中的装置更换路线,ruby-on-rails,devise,routes,gem,Ruby On Rails,Devise,Routes,Gem,我使用的是rails 4.1.1 我希望用户遵循的过程是使用基本设计表单注册,这样就可以使用电子邮件、密码和密码确认。当用户提交此文件时,我希望他们直接进入编辑配置文件页面。新用户注册页面的底部如下。我尝试了一些事情,但每件事都让我犯错误。任何帮助都将不胜感激!我还包括了我的设计链接,因为我认为这是我应该寻找的地方 <div class="form-group"> <%= f.label :password_confirmation %> <%
<div class="form-group">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control" %>
</div>
<div class="form-group">
<%= f.submit "Sign up", class: "btn btn-primary" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
这是我的应用程序控制器
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:name, :email, :password) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:name, :line1, :line2, :town, :county, :postcode)}
end
private
def after_sign_up_path_for(resource)
edit_user_registration_path
end
end
class ApplicationController
要更改注册后的行为,您必须在application\u controller.rb中为方法覆盖designe的注册后路径:
class ApplicationController < ActionController::Base
private
def after_sign_up_path_for(resource)
edit_user_registration_path(current_user) #basically whichever path you think meets your needs
end
end
class ApplicationController
另外,我还想从编辑用户注册页面直接转到结帐页面(我使用的是stripe),感谢advanceAfraid不再直接指向主页?我的路由是否丢失了其他内容?重新启动服务器,这正在工作,因为我已经在我的应用程序上测试了它。我刚刚尝试过,但肯定仍然重定向到我的主页!??嘿,运气好吗?还是没有乐趣恐怕还是会转到主页?!
class ApplicationController < ActionController::Base
private
def after_sign_up_path_for(resource)
edit_user_registration_path(current_user) #basically whichever path you think meets your needs
end
end