我正在跑步:
我使用RailsApp启动应用程序来设置设计和专家。现在我无法进行嵌套表单属性保存。我收到一个错误:
Unpermitted parameters: players
我编辑了初始化文件以显示:
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :last_name, :players, :player_attributes => [:position]) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:first_name, :last_name, :role, :players, :player_attributes => [:position]) }
end
我的模特是:
class Users < ActiveRecord::Base
has_one :player
accepts_nested_attributes_for :player
end
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class Players < ActiveRecord::Base
belongs_to :user
end
玩家控制器
def update
@player = Player.find[params[:id])
if @player.update_attributes(secure_params)
redirect_to players_path, :notice => "Player updated"
else
redirect_to players_path, :alert => "Unable to update"
end
end
private
def secure_params
params.require(:user).permit(:user_id, :players)
end
我做错了什么?
答案 0 :(得分:1)