惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
博客园 - 聂微东
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
小众软件
小众软件
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
量子位
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗

Codebase Audits & Rescue | Ally Piechowski

Most of your tech debt is free Your Setup Script Should Support Git Worktrees How to Be a Good Open Source Maintainer "The Git Commands I Run Before Reading Any Code" "Ruby 3.2 Is EOL: What You Actually Need to Do" "Rails 7.2 to 8.1 Upgrade: What Actually Breaks and How to Fix It" "Why Your Engineering Team Is Slow (It's the Codebase, Not the People)" "Migrating from Sprockets to Propshaft: Is It Worth It?" "How to Close a Tab in Vim" "How I Audit a Legacy Rails Codebase in the First Week" "How to Open a New Tab in Vim" "Rails default_scope: Why You Should Never Use It" "Solved: Warning: Using the last argument as keyword parameters is deprecated" "Vim: How to Open Current Opened File in New Tab" "Rails: How to Use Greater Than/Less Than in Active Record where Statements" "What is the best time for stand-up meetings?" "Using Let and Context to Modularize RSpec Tests" "What Is Fed vs Unfed Sourdough Starter?" "My Father, My Mentor, My Teacher" "How to Get Over Burnout" "What's the difference between a Good Developer and a Good Googler?" Codebase Audits & Rescue | Ally Piechowski
"Solved: ActionController::ParameterMissing (param is mis...
"Ally Piechowski" · 2020-01-03 · via Codebase Audits & Rescue | Ally Piechowski

When using Ruby on Rails' strong_params with require, there is a chance the key doesn't exist. When this happens, an ActionController::ParameterMissing exception is thrown.

Ally Piechowski · · 1 min read
Solved: ActionController::ParameterMissing (param is missing or the value is empty)

In Ruby on Rails, strong_params are a necessity to work with ActionController parameters, but sometimes an exception of ActionController::ParameterMissing is thrown… Why?

The Code

params.require(:message).permit(:text, :author_id)

The Exception

ActionController::ParameterMissing (param is missing or the value is empty: message)

The Fix

The error is occurring because our params hash does not include the root key :message. We can diagnose this issue by utilizing params.inspect in either an interactive console or printing the output of certain commands.

The command I tend to use most to identify mishaps is params.inspect.

For example, the output of this command might be:

<ActionController::Parameters {"messages"=>{"text"=>"My Message", "author_id"=>1337}} permitted: false>

In this case, it appears as though there is a typo in our view! The key was typed as messages rather than message. The fix is easy, change the view to submit message instead.


Related Articles