"表格中的第一个参数不能包含nil或为空"窃听器

时间:2015-03-19 06:59:48

标签: javascript jquery html ruby-on-rails-4

大家好我希望有人帮我修复这个错误.....我想注册一个帐户但是每当我点击注册时我都会失败并且我得到上面的错误...任何可以帮我修复的人这个 请帮帮我,我试过,我不明白为什么.. 以下是我负责所有控制器的代码 注册控制器的代码

class RegistrationsController < Devise::RegistrationsController
    #include Wicked::Wizard
    #before_filter :configure_permitted_parameters, if: :devise_controller?
def new
  super
end

def create
  super
end

protected

def after_inactive_sign_up_path_for(resource)
    user_steps_path
  end
end 

下面是user_steps控制器的代码

    class UserStepsController < ApplicationController
    include Wicked::Wizard
      steps :finishing_step

      def show
        @user = User.last
        render_wizard
      end

      def update
        render_wizard
      end
    private
        def finish_wizard_path
          current_user.update_attributes(complete: true)
          redirect_to root_path
        end
    end
below is my code for the applications controller

class ApplicationController < ActionController::Base
   layout :layout_by_resource
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :configure_permitted_parameters, if: :devise_controller?


  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, :alert => exception.message
  end

  before_filter do
    resource = controller_name.singularize.to_sym
    method = "#{resource}_params"
    params[resource] &&= send(method) if respond_to?(method, true)
  end

  def after_sign_in_path_for(resource)
    #this is where i decide that before user fills all fields he/she should be redirected to the user_steps_path
    if resource.complete?
      root_path    
    else
      user_steps_path
    end
  end

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:first_name, :last_name, :phone_number,
     :city, :nationality, :address_first_line, :address_second_line, :date_of_birth, 
     :email, :password, :password_confirmation, :terms_of_service )}
  end
   protected

  def layout_by_resource
    if devise_controller?
      "login"
    else
      "application"
   end
  end

  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, :email, :password, :current_password, :is_female, :date_of_birth, :avatar) }
  end

end

下面是我在个人电子邮件确认后要提交给用户帐户的表单的代码

<%= form_for @user, url: wizard_path do |f| %>
<div><%= f.label :first_name, "First Name" %><br />
    <%= f.text_field :first_name %></div>
  <div><%= f.label :middle_name, "Middle Name" %><br />
    <%= f.text_field :middle_name %></div>
  <div><%= f.label :last_name, "Last Name" %><br />
    <%= f.text_field :last_name %></div>
  <div><%= f.label :phone_number, "Phone Number" %><br />
    <%= f.text_field :phone_number %></div>
  <div><%= f.label :date_of_birth, "Date of Birth" %><br />
    <%= f.date_select :date_of_birth, start_year: 1900 %></div>
  <div><%= f.label :address_first_line, "Address (first line)" %><br />
    <%= f.text_field :address_first_line %></div>
  <div><%= f.label :address_second_line, "Address (second line)" %><br />
    <%= f.text_field :address_second_line %></div>
  <div><%= f.label :city, "City" %><br />
    <%= f.text_field :city %></div>
  <div><%= f.label :nationality, "Nationality" %><br />
    <%= country_select(:user, :nationality, {selected: "UG"}) %></div>
    <div>
    <%= f.label :avatar %>
    <%= f.file_field :avatar %>
  </div>
  <div>
    <%= f.label :terms_of_service, "Agree to Terms of Service" %> <br>
    <%= f.check_box :terms_of_service %>
  </div>
  <div><%= f.submit "Register" %></div>
  <% end %>

提前感谢任何帮助.....

0 个答案:

没有答案