ActionController:UnknownFormat respond_to do | format |

时间:2017-04-08 06:03:45

标签: javascript ruby-on-rails ajax formatting

我正在尝试使用Devise注册用户,如果注册中包含某个参数,则呈现JS文件。我收到以下错误:

ActionController::UnknownFormat in RegistrationsController#create
ActionController::UnknownFormat

这是我的“创建”操作(我标记了错误指向的行):

if resource.persisted?
  if resource.active_for_authentication?
    set_flash_message :notice, :signed_up if is_flashing_format?
    sign_up(resource_name, resource)
    if !params[:name].nil?
      View.create(name: params[:name])
      respond_to do |format| #THIS IS THE LINE WITH THE ERROR
        format.js
      end
    else
      respond_with resource, location: after_sign_up_path_for(resource)
    end
  else
    respond_with resource, location: inactive_path_for(resource)
  end
else
  respond_with resource
end

行动是“创建”,位于app/controllers/registrations_controller.rb。我正在尝试渲染的JS文件是app/views/devise/registrations/create.js.erb

我怀疑找到文件有问题,但我无法弄清楚如何将其指向正确的路线,或者这是否是正确的问题。有人有什么想法吗?

0 个答案:

没有答案