Skip to content

Getting MissingAttributeError when submitting a value in the form with trailing whitespace #97

@jmuheim

Description

@jmuheim

I have a Page model that translates :title, :navigation_title, :lead, :content.

class Page < ApplicationRecord
  extend Mobility
  translates :title, :navigation_title, :lead, :content
end

I'm using the following config:

Mobility.configure do |config|
  config.default_backend = :column
  config.accessor_method = :translates
  config.query_method    = :i18n
  config.default_options = {
    fallbacks: { de: :en }
  }
end

I noticed a strange behaviour: whenever I submit a value using the form with a trailing whitespace (e.g. _x, _x_, or x_, where whitespace is substituted with an underscore) to a translated field (e.g. lead) I get the following error:

ActiveModel::MissingAttributeError at /de/pages/1
can't write unknown attribute `lead`

If I submit any other value (e.g. x`), it works perfectly.

This only happens to translated fields, not to other fields.

Any idea what's going on? I'm happy to provide more details if needed.

Here's the app I'm currently working on: jmuheim/base#86

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions