arogachev
arogachev

Reputation: 33538

Empty form values are not included in params in Active Admin

Resource form contents:

form do |f|
  f.inputs do      
    f.input :name
  end

  f.actions
end

I am using Rails 5 beta 3, here is Gemfile contents:

# Backend
gem 'activeadmin', github: 'activeadmin/activeadmin', branch: 'master'

Gemfile.lock contents:

GIT
  remote: git://github.com/activeadmin/activeadmin.git
  revision: f7483e3b8fcd74437b03c18fb658dac62a9fc62e
  branch: master
  specs:
    activeadmin (1.0.0.pre2)
      arbre (~> 1.0, >= 1.0.2)
      bourbon
      coffee-rails
      formtastic (~> 3.1)
      formtastic_i18n
      inherited_resources (~> 1.6)
      jquery-rails
      jquery-ui-rails
      kaminari (~> 0.15)
      rails (>= 3.2, < 5.0)
      ransack (~> 1.3)
      sass-rails
      sprockets (< 4)

Even attribute is included in permitted params:

permit_params :name

it's missing in params when I submit empty value and as a result name is not updated. Non-empty values work OK.

Same with select boxes.

After error occured, I tried to update Active Admin with:

bundle update activeadmin

but error still remains.

I tested it on simple rails form (generated by scaffold command) and formtastic outside of Active Admin resource, both options work, so it seems to be Active Admin problem.

Here is how I checked params content (also checked logs/development.log):

controller do
  def update
    abort params.inspect
  end
end

So name is not presented even at this moment.

I posted issue here but no feedback till now.

Upvotes: 0

Views: 654

Answers (1)

micred
micred

Reputation: 1532

Since you are using rails5.0.0beta2, you are probably also using rack 2.0.0.alpha.

This is caused by a bug in rack.

Until rack2.0.0 become stable, you can solve this bug by adding to the Gemfile:

gem 'rack', github: 'rack/rack'

Upvotes: 1

Related Questions