1
路由是正確的,不知道還有什麼是關閉的? 在「更新」頁面(當路由更新)我得到的錯誤param丟失或者值爲空:用戶(devise rails gem)
參數是丟失或爲空值:用戶
這是謀害我的第二個自定義視圖頁面另一個正在使用類似的代碼。
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| %>
你在哪裏創建@user? – Thorin
@Thorin假設有用戶的「at」符號(溢出限制了他們在評論中的使用) line 2 user = User.find(current_user.id) – whataboutme1
需要看到你形成參數和表單代碼,你能否更新? –