RubyMoney/money-rails

Get unknown field error when trying to parse params

TTD93 opened this issue · 0 comments

TTD93 commented

We've done the following:

# migration
class AddDataToPosts < ActiveRecord::Migration[6.1]
  def change
    add_column :posts, :data, :jsonb, default: {}
  end
end

# model: 
class Post < ApplicationRecord
  jsonb_accessor :data,
                 body:                     :string,
                 sending_method: string
end

Gem version 1.3.2
Rails version 6.1.4
Ruby version 2.6.7

When I try to do the following:

params =  params.permit(:body, :sending_method)
Post.new(params)

I get the error message UNHANDLED ERROR unknown attribute 'body' for Post.

This is the param:
#<ActionController::Parameters { "sending_method"=>"email", "body"=>"<div>Fake body</div>"} permitted: true>

However, when I do this, it works

new_post = Post.new
new_post.body = "fake body string"
new_post.save!"