2016-07-31 6 views
-1

これはprofile.rbがimage.rbからネストされた属性を持つは、私はこのエラーを受け取っ:ネストされたパラメータで '許可されていないパラメータイメージ' を

def create 

@profile = current_user.build_profile(profile_params) 

    if @profile.save 
    else 
    render :new 
    end 
end 
end 

profiles_controller.rbある

params.require(:profile).permit(:first_name, :last_name, :phone_no, image_attributes: [:id,:image,:imageable_id,:imageable_type]) 

profile.rb

class Profile < ActiveRecord::Base 
belongs_to :user 
has_one :image , :as => :imageable 
accepts_nested_attributes_for :image 
end 

これは、これが@Sergeyソコロフこれを解決thnks

<%= f.fields_for :image do |ff| %> 
    <%= f.label :image %> 
    <%= f.file_field :image %> 
    <% end %> 

答えて

0
<%= f.fields_for :image do |ff| %> 
    <%= ff.label :image %> 
    <%= ff.file_field :image %> 
<% end %> 
+0

profile.rbモデルから_form.html.erbあるimage.rb

class Image < ActiveRecord::Base belongs_to :imageable, polymorphic: true mount_uploader :image, ImageUploader end 

あります – fahad

関連する問題