在Devise中自定义路由到新用户注册页面Simple_Form_For将新表单发布到设计注册控制器

一个想法 – 我应该制作一个inheritance注册控制器的新控制器吗? 然后做另一个

devise_for :users, :controllers => {:registration => "newcontroller"} 

将trial_signup.html.erb更改为new.html.erb

并在app / views / devise / registrations2 / new.html.erb中创建一个新文件夹

最新更新 app / views / devise / trial_signup.html.erb

 

Trial Sign up

resource_name, :url => sales_path(resource_name)) do |f| %>
true, :input_html => { :class => "form-control" } %>
{ :class => "form-control" } %>
true, :input_html => { :class => "form-control" } %> true, :input_html => { :class => "form-control" } %> true, :input_html => { :class => "form-control" } %>

我有一个user.rb模型

 has_many :trial_subscriptions attr_accessible :trial_subscriptions_attributes accepts_nested_attributes_for :trial_subscriptions, :allow_destroy => true 

我有一个trial_subscription.rb模型,它inheritance自manual_subscription.rb并且inheritance自subscription.rb

Subscription.rb模型

 belongs_to :user 

我的任务是创建一个trial_signup.html.erb来发布表单(创建用户及其相关的试用帐户)

我正在努力学习设计和simple_form_for。


在我的路线

我有这个

 devise_for :users, :controllers => {:registrations => "registrations"} 

如果我去用户/ sign_up我正在渲染app / views / devise / registrations / new.html.erb

我将new.html.erb的相同副本复制到了trial_signup.html.erb中

 app/views/devise/registrations/trial_signup.html.erb 

我把它添加到我的路线中

  devise_scope :user do get "sales", to: "registrations#trial_signup" end 

我可能误认为devise_scope的目的。 我不完全理解这一部分。

我是否使用指向注册试用注册操作的用户模型获取销售页面? 请注意,我希望trial_signup.html.erb在注册控制器中点击create方法(来自devise)。 它是否在我的注册控制器中命中空的trial_signup操作?

我的forms是这样的

  resource_name, :url => registration_path(resource_name)) do |f| %> 

当我做rake路线我有这个

 new_user_registration GET /users/sign_up(.:format) registrations#new sales GET /sales(.:format) registrations#trial_signup 

**我没有registration_path? 这是为了什么?

更新

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

<%= simple_form_for(resource, :as => resource_name, :url => sales_path) do |f| % <%= simple_form_for(resource, :as => resource_name, :url => sales_path) do |f| % >

执行rake routes并检查为get "sales"路由生成的路径(主要是user_sales_path:在prefix列下检查),将其作为url选项传递给表单。 因此,在表单提交时,将调用自定义RegistrationsController#trial_signup操作。