自定义设计更新表单不保存更改

时间:2014-10-06 19:10:52

标签: ruby-on-rails ruby-on-rails-4 devise

我有一个自定义Devise表单,我想更新我的设计用户。但是,并没有保存这些变化。

形式:

      .small-12.columns
        .well
          =form_tag(test_registration_path, method: 'PUT', id: "my-awesome-dropzone.dropzone") do 
            .row
              .small-4.columns
                %input#photo-dropzone{:name => "file", :type => "file"}/
              .small-8.columns
                .row
                  .small-12.columns
                    = label_tag :name
                    = text_field_tag :name
                    = submit_tag "Submit", class: "button button-green"

日志:

    Started PUT "/tests" for 127.0.0.1 at 2014-10-06 11:48:04 -0700
    Processing by Tests::Devise::RegistrationsController#update as HTML
      Parameters: {"utf8"=>"✓", "authenticity_token"=>"0R7keMt16tsIdjawQHE7yq15Ye6V/w5I4klAvs1WWLY=", "name"=>"testt",  "commit"=>"Submit"}
      Artist Load (0.4ms)  SELECT  "artists".* FROM "artists"  WHERE "artists"."id" = 19  ORDER BY "artists"."id" ASC LIMIT 1
      Artist Load (0.2ms)  SELECT  "artists".* FROM "artists"  WHERE "artists"."id" = $1 LIMIT 1  [["id", 19]]
       (0.1ms)  BEGIN
       (0.1ms)  COMMIT
    Redirected to http://site.dev/artists/19
    Completed 302 Found in 5ms (ActiveRecord: 0.8ms)

RegistrationsController#更新

 def update
        # For Rails 4
        account_update_params = devise_parameter_sanitizer.sanitize(:account_update)
        # For Rails 3
        # account_update_params = params[:user]

        # required for settings form to submit when password is left blank
        if account_update_params[:password].blank?
          account_update_params.delete("password")
          account_update_params.delete("password_confirmation")
        end

        @user = Test.find(current_test.id)
        if @user.update_attributes(account_update_params)
          set_flash_message :notice, :updated
          # Sign in the user bypassing validation in case their password changed
          sign_in @user, :bypass => true
          redirect_to artist_path(@user)
        else
          render "edit"
        end
      end

我需要做些什么来正确更新我的参数?

1 个答案:

答案 0 :(得分:0)