通过活动管理员传递强参数

时间:2014-03-18 21:34:51

标签: ruby-on-rails-4 activeadmin strong-parameters

这让我很生气。我有一个关联,我想通过活动管理员进行编辑。但它不会允许这些愚蠢的属性,而不管我是怎么做的。对我做错的任何建议?

ActiveAdmin.register User do
      index do
        column :email
        default_actions  
      end

      form do |f|
        f.inputs "Details" do
          f.input :email
          f.input :groups
        end
         f.actions
      end
      # See permitted parameters documentation:
      # https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
      #
      #
      # or
      #
      # permit_params do
      #  permitted = [:permitted, :attributes]
      #  permitted << :other if resource.something?
      #  permitted
      # end

      permit_params :group_ids, :group_id, :email, groups_attributes: [:group_ids, :grup_id]


    end

微量

Started PATCH "/admin/users/1" for 127.0.0.1 at 2014-03-18 22:31:55 +0100
Processing by Admin::UsersController#update as HTML
  Parameters: {"utf8"=>"â", "authenticity_token"=>"VrWG/H2HMQTlRRHGQ76ETwNoPWtei0ldmmtcnmu4nTI=", "user"=>{"email"=>"gjores@gmail.com", "group_ids"=>["", "", "13"]}, "commit"=>"Update User", "id"=>"1"}
  AdminUser Load (0.2ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 1 ORDER BY "admin_users"."id" ASC LIMIT 1
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", "1"]]
Unpermitted parameters: group_ids
Unpermitted parameters: utf8, _method, authenticity_token, commit, id
   (0.1ms)  begin transaction
   (0.1ms)  commit transaction
Redirected to http://localhost:3000/admin/users/1
Completed 302 Found in 13ms (ActiveRecord: 0.4ms)

1 个答案:

答案 0 :(得分:0)

我通过参考正确的模型解决了它。我有一个加入模型,我从一开始就应该与之合作。