将RoR注册脚本添加到引导模式中

所以我试图在Bootstrap模式中创建一个注册脚本,但它失败了。

相同的脚本在其赢得的页面上工作,只是不确定为什么它在这里不起作用。

使用bootstrap有什么特别之处吗?

这是错误: Rails错误

以下是模态内容

这是我的用户控制器

 class UsersController < ApplicationController def new @user = User.new end end 

和用户模型

 class User < ApplicationRecord has_secure_password end 

最后我的db:为我的用户迁移文件

 class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :first_name t.string :last_name t.string :email t.string :password_digest t.timestamps end end end 

还有一点是我的路线

 Rails.application.routes.draw do root 'home#index' get 'signup' => 'users#new' resources :users end 

在Ruby中,您可以引用实例变量,即使它尚未初始化:

 irb(main):001:0> @foo => nil 

这正是这里发生的事情。 如果你想在一堆动作上使用相同的表格而不用担心控制器是否设置了@user实例变量你可以只使用|| (或)运营商:

 <%= form_for(@user || User.new) do |f| %> # ... <% end %>