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
需要看到你形成参数和表单代码,你能否更新? –