undefined local variable or method `asistencia_params' for #<AsistenciaController:0x00000000083450>

huangapple go评论101阅读模式
英文:

undefined local variable or method `asistencia_params' for #<AsistenciaController:0x00000000083450>

问题

  1. class AsistenciaController &lt; ApplicationController
  2. def asistencia
  3. @username = params[:user_username]
  4. @entry = params[:user_entry]
  5. if @asistencia.update(asistencia_params)
  6. redirect_to asistencia_path, notice: &quot;Asistencia Guardada&quot;
  7. else
  8. render :edit, status: :unprocessable_entity
  9. end
  10. end
  11. end
  12. 未定义局部变量或方法 `asistencia_params` 用于 #&lt;AsistenciaController:0x00000000083450&gt;
  13. 我期望能够通过名称来更新该条目
  14. 我想强调在其他控制器中,所有的用户名和条目都已经定义。
英文:
  1. class AsistenciaController &lt; ApplicationController
  2. def asistencia
  3. @username = params[:user_username]
  4. @entry = params[:user_entry]
  5. if @asistencia.update(asistencia_params)
  6. redirect_to asistencia_path, notice: &quot;Asistencia Guardada&quot;
  7. else
  8. render :edit, status: :unprocessable_entity
  9. end
  10. end
  11. end
  12. undefined local variable or method `asistencia_params&#39; for #&lt;AsistenciaController:0x00000000083450&gt;

I expected to be able to update the entry with the use of the name

I want to emphasize that in other controllers all the usernames, entries are already defined.

答案1

得分: 1

你需要在你的控制器中定义方法 asistencia_params,像这样:

  1. def asistencia_params
  2. # 在这里你可以允许或进行其他你需要的操作
  3. # (例如,params 赋值或只允许处理所需的参数)
  4. params.require(:asistencia).permit(:user_name, :user_entry, 等等..)
  5. end
英文:

You have to define the method asistencia_params like this in your controller.

  1. def asistencia_params
  2. #here you can permit or do whatever you want
  3. (eg params assignment or permiting only required params for processing)
  4. params.require(:asistencia).permit(:user_name, :user_entry, etc..)
  5. end

huangapple
  • 本文由 发表于 2023年6月11日 21:36:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450722.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定