1
路由是正確的,不知道還有什麼關閉? 在「更新」頁面(當路由更新)我得到的錯誤param丟失或值爲空:用戶(設計寶石)
參數是丟失或爲空值:用戶
這是謀害我的第二個自定義視圖頁面另一個正在使用類似的代碼。
routes-
devise_for :users, controllers: {registrations: 'users/registrations'} as :user do
end
root 'home#home'
get 'users/discovery_settings' => 'users#discovery_settings'
patch 'users/discovery_settings/update' => 'users#update_discovery'
我的用戶控制器 -
def update_discovery
@user = User.find(current_user.id)
if @user.update(user_params2)
# Sign in the user by passing validation in case their password changed
sign_in @user, :bypass => true
redirect_to root_path
else
render "edit"
end
end
def user_params2
# NOTE: Using `strong_parameters` gem
params.require(:user).permit(:discovery, :male, :female, :min_age, :max_age)
end
然後我的觀點的form_for呼籲
<%= form_for(@user, :url => { :action => "update_discovery" }, html: {class: "form floating-label"}) do |f| %>