Skip to content

Rails Unpermitted Parameters Fix

DodaTech Updated 2026-06-24 1 min read

In this tutorial, you'll learn about Rails Unpermitted Parameters Fix. We cover key concepts, practical examples, and best practices.

The Problem

Form submissions result in missing fields in the database, or Rails raises ActionController::UnpermittedParameters or Unpermitted parameter: field_name. The data is submitted but not saved.

Quick Fix

Step 1: Permit the missing parameters

class UsersController < ApplicationController
  def create
    @user = User.new(user_params)
    @user.save
  end

  private

  def user_params
    params.require(:user).permit(:name, :email, :password)
  end
end

Step 2: Log unpermitted parameters

config.action_controller.action_on_unpermitted_parameters = :log

Expected: Check the logs for parameter names.

Step 3: Permit nested parameters

def user_params
  params.require(:user).permit(
    :name, :email,
    addresses: [:street, :city, :zip],
    roles: []
  )
end
def user_params
  params.require(:user).permit!
end

Expected: Use only during development or for trusted admin actions.

Step 5: Check form field names

<%= form_with model: @user do |form| %>
  <%= form.text_field :name %><br>
  <%= form.email_field :email %><br>
<% end %>

Prevention

  • Always explicitly permit all expected parameters.
  • Use :log action to see unpermitted params during development.
  • Keep strong parameters in the private section of controllers.

Common Mistakes with parameters not permitted

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world RAILS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What are strong parameters in Rails?

A security feature requiring explicit permission for controller parameters. Only permitted parameters are passed to the model, preventing mass assignment attacks.

Why does my nested form not save?

Nested parameters must be permitted explicitly, and the model must have accepts_nested_attributes_for.

Can I permit all parameters globally?

Yes, but it defeats the purpose of strong parameters. Use permit! only in specific actions that need it.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro