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

推荐订阅源

Y
Y Combinator Blog
宝玉的分享
宝玉的分享
月光博客
月光博客
小众软件
小众软件
Jina AI
Jina AI
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Blog — PlanetScale
Blog — PlanetScale

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