带有Hstore列的活动管理表单 - 未允许的参数错误

时间:2016-02-05 07:16:12

标签: ruby-on-rails-4 activeadmin hstore

我正在使用ActiveAdmin(1.0.0.pre1)和Rails 4.2.0。

我有一个模型hstore。它有一个current_addressUnpermitted parameters: current_address

对于这个hstore列,我有一个名为full_address的键,我想要一个编辑。 我按照这个链接https://github.com/activeadmin/activeadmin/issues/2032来实现这一目标。表单正确加载。

但是我收到了错误current_address正如您所看到的,我已在permit_params列表中添加了ActiveAdmin.register Provider do permit_params :dob, :current_address menu parent: 'User' config.sort_order = 'id_asc' actions :all, except: [:new] filter :mobile_number filter :id index do selectable_column column :id column :mobile_number column :name column :gender column :dob column :current_address actions end form do |f| f.inputs 'Provider Details' do f.input :dob, as: :datepicker f.fields_for :current_address do |current_address| current_address.input :full_address, input_html: {value: f.object.current_address. try(:[], 'full_address')} end end f.actions end end

有谁能告诉我这里出了什么问题,我该怎么办呢?谢谢:))

private void Form1_Paint(object sender, PaintEventArgs e)
        {
            IntPtr desktop = GetDC(IntPtr.Zero);
            using (Graphics g = Graphics.FromHdc(desktop))
            {
                g.FillRectangle(Brushes.Red, 0, 0, 100, 100);
            }
            ReleaseDC(IntPtr.Zero, desktop);
        }

1 个答案:

答案 0 :(得分:2)

当你在强参数中允许:current_address时,它只允许标量值。 https://github.com/rails/strong_parameters#permitted-scalar-values

因此您需要为哈希指定允许的密钥。在你的情况下,只需写:

permit_params :dob, { current_address: [:full_address, :any_other_custom_key] }