Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 4-设计不使用自定义控制器_Ruby On Rails_Ruby_Devise - Fatal编程技术网

Ruby on rails Rails 4-设计不使用自定义控制器

Ruby on rails Rails 4-设计不使用自定义控制器,ruby-on-rails,ruby,devise,Ruby On Rails,Ruby,Devise,我在Rails应用程序中使用Desive,我想定制它的一些行为。我已经阅读了design\u for的文档。但我无法让它使用我的自定义控制器。我的溃败是这样的: devise_for :users, controllers: { sessions: "users/sessions", registrations: "users/registrations" } = render "users/registrations/modal_form" .modal.fade#registra

我在Rails应用程序中使用Desive,我想定制它的一些行为。我已经阅读了
design\u for
的文档。但我无法让它使用我的自定义控制器。我的溃败是这样的:

devise_for :users, controllers: {
  sessions: "users/sessions",
  registrations: "users/registrations"
}
= render "users/registrations/modal_form"
.modal.fade#registrations_modal{ tabindex: -1, role: 'dialog', "aria-labelledby" 
  [..]
  = render "users/registrations/new_form"
  [..]
= form_for(resource, as: resource_name, url: registration_path(resource_name))  do |f|
  = devise_error_messages!
  .form-group
    = f.label :name
    = f.text_field :name, autofocus: true, class: "form-control"
  .form-group
    = f.label :email
    = f.email_field :email, class: "form-control"

  .form-group
    = f.label :password
    - if @minimum_password_length
      %em
        (#{@minimum_password_length} characters minimum)
    = f.password_field :password, autocomplete: "off", class: "form-control"

  .form-group
    = f.submit "Sign up", class: "btn btn-default"

- if current_page?(new_user_registration_path)
  = render "devise/shared/links"
在my
Users::RegistrationController
中,我尝试了以下方法:

# POST /resource
def create
  puts "I'm here" # never happens!
  super
end
你知道我遗漏了什么吗

更新

以下是我的文件结构:

更新2

我想我可能找到了问题的根源。我以引导模式在默认设计路径之外的另一条路径上呈现和呈现我的注册表单

我在此路径上呈现表单:

/apps/1/edit
而不是:

users/sign_up
如果我在这个路径上注册
users/sign\u
,它就会工作,我的方法就会被调用。在我的
/apps/1/edit
视图中,我呈现如下表单:

devise_for :users, controllers: {
  sessions: "users/sessions",
  registrations: "users/registrations"
}
= render "users/registrations/modal_form"
.modal.fade#registrations_modal{ tabindex: -1, role: 'dialog', "aria-labelledby" 
  [..]
  = render "users/registrations/new_form"
  [..]
= form_for(resource, as: resource_name, url: registration_path(resource_name))  do |f|
  = devise_error_messages!
  .form-group
    = f.label :name
    = f.text_field :name, autofocus: true, class: "form-control"
  .form-group
    = f.label :email
    = f.email_field :email, class: "form-control"

  .form-group
    = f.label :password
    - if @minimum_password_length
      %em
        (#{@minimum_password_length} characters minimum)
    = f.password_field :password, autocomplete: "off", class: "form-control"

  .form-group
    = f.submit "Sign up", class: "btn btn-default"

- if current_page?(new_user_registration_path)
  = render "devise/shared/links"
我的
apps\u controller
(提交注册表单的操作)的编辑操作当前为空:

# GET /apps/1/edit
def edit
end
我的
用户/注册/modal_表单
部分的相关部分如下所示:

devise_for :users, controllers: {
  sessions: "users/sessions",
  registrations: "users/registrations"
}
= render "users/registrations/modal_form"
.modal.fade#registrations_modal{ tabindex: -1, role: 'dialog', "aria-labelledby" 
  [..]
  = render "users/registrations/new_form"
  [..]
= form_for(resource, as: resource_name, url: registration_path(resource_name))  do |f|
  = devise_error_messages!
  .form-group
    = f.label :name
    = f.text_field :name, autofocus: true, class: "form-control"
  .form-group
    = f.label :email
    = f.email_field :email, class: "form-control"

  .form-group
    = f.label :password
    - if @minimum_password_length
      %em
        (#{@minimum_password_length} characters minimum)
    = f.password_field :password, autocomplete: "off", class: "form-control"

  .form-group
    = f.submit "Sign up", class: "btn btn-default"

- if current_page?(new_user_registration_path)
  = render "devise/shared/links"
我的
用户/注册/新表单
如下所示:

devise_for :users, controllers: {
  sessions: "users/sessions",
  registrations: "users/registrations"
}
= render "users/registrations/modal_form"
.modal.fade#registrations_modal{ tabindex: -1, role: 'dialog', "aria-labelledby" 
  [..]
  = render "users/registrations/new_form"
  [..]
= form_for(resource, as: resource_name, url: registration_path(resource_name))  do |f|
  = devise_error_messages!
  .form-group
    = f.label :name
    = f.text_field :name, autofocus: true, class: "form-control"
  .form-group
    = f.label :email
    = f.email_field :email, class: "form-control"

  .form-group
    = f.label :password
    - if @minimum_password_length
      %em
        (#{@minimum_password_length} characters minimum)
    = f.password_field :password, autocomplete: "off", class: "form-control"

  .form-group
    = f.submit "Sign up", class: "btn btn-default"

- if current_page?(new_user_registration_path)
  = render "devise/shared/links"

我对迪安不太熟悉。你知道我在什么地方遗漏了什么吗?

我想我已经解决了。问题出现在我的
表格中,当时我使用了错误的路线。我没有使用默认的
注册路径
作为
url
而是使用:

user_registration_path(resource_name)

愚蠢的错误。遇到了另一个问题,我现在一直得到:
ActionController::UnknownFormat
。但它现在至少在使用我的自定义控制器

我想我解决了。问题出现在我的
表格中,当时我使用了错误的路线。我没有使用默认的
注册路径
作为
url
而是使用:

user_registration_path(resource_name)

愚蠢的错误。遇到了另一个问题,我现在一直得到:
ActionController::UnknownFormat
。但它现在至少在使用我的自定义控制器

尝试放置除“我在这里”以外的其他内容,尝试放置
调试器,查看是否在创建操作时应用程序暂停?或者只需删除
super
即可查看操作
create
是否仍能正常工作?尝试使用
byebug
gem()设置断点。但它似乎从未被调用。您是否尝试重新启动rails服务器?你把
Users::RegistrationsController
放在哪里?试试这个
Users::RegistrationsController
如果你在你的自定义控制器中创建了一个GET操作,比如
new
,并让它输出一些文本,比如
返回“hello”
,那么会发生什么呢?试着放置
put之外的其他东西“我在这里”
,尝试放置
调试器
并查看是否在创建操作时应用程序暂停?或者只是删除
super
以查看操作
create
是否仍能正常工作?尝试使用
byebug
gem()设置断点。但它似乎从未被调用。您是否尝试重新启动rails服务器?您将
用户::注册控制器
放在何处?尝试此
用户::注册控制器<设计::注册控制器
如果在自定义控制器中创建一个GET操作,例如
新建
,并使其输出一些tex,会发生什么t不喜欢
返回“hello”