0.0
No release in over 3 years
Low commit activity in last 3 years
convert request parameter to suffix '_attributes'
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 6.0.1
 Project Readme

WrapAttributes

test

add '_attributes' suffix in rails

Usage

class ApplicationController < ActionController::API
  include WrapAttributes::AttributesWrapper # <- add
end
 # request parameter
 # { 'username' => 'tanmen', 'posts' => [{'text' => 'hallo'}] }
 # ↓
 # wrapped parameter
 # { 'username' => 'tanmen', 'posts_attributes' => [{'text' => 'hallo'}] }
class UsersController < ApplicationController
  wrap_attributes :posts # <- add

  private

  def user_params
    params.require(:user).permit(:username, :posts_attributes)
  end
end

Installation

Add this line to your application's Gemfile:

gem 'wrap_attributes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install wrap_attributes

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.