如何从此获得唯一的need_attributes
?
def needy_params
params.require(:needy).permit(:user_name, :user_email, :needs_attributes: [:name, :description, :amount_required, :country_id, :city_id])
end
我是否可能只从此获得needs_attributes
或者像这样编写新方法?
def need_param
params.require(:needy.needs_attributes).permit(:name, :description, :amount_required, :country_id, :city_id)
end
答案 0 :(得分:1)
这对你有用:
def needs_attributes_param
params.require(:needy).require(:needs_attributes).permit(
:name, :description, :amount_required, :country_id, :city_id
)
end