牛。试了一下。
前同事的贴,顶顶顶
@rails_on_ll 我的计划已经排满了。哦嚯嚯
@small_fish__ 3Q,我一开始找到 php 的 Base64_decode 上去了。- - ||。但是不会 PHP
用 ajax 做上去。
@martin 这联系地址,我注意很久了。
@martin 在魔都,我一直在寻找 MAC,一直被贫穷压着。(摩擦~摩擦)
@gsky 
   () 
  /oo\______
  \ /     ---\
   \/    /  \  \
    \|__\_|/  *
      ||  YY|
      ||  ||   
膜拜楼主神结尾,突然发现偶好纯洁。
这孩子肯定没好好学语文!
我是打杂加写代码的。
可以结贴了。。。。
找到错误了。我在 image 中用了多态,第一次用,所以搞错了。 在 migrate 中的 create_images
class CreateImages < ActiveRecord::Migration
  def up
    create_table :images do |t|
      t.references :imageable, polymorphic: true
      t.boolean :is_index
      t.timestamps
    end
  end
  def down
    drop_table :images
  end
end
model 中的 image.rb
belongs_to :imageable, polymorphic: :true
  has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
  validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
在 controller 中 good_controller.rb
def create
    @good = Good.new(good_param)
    if @good.save
      redirect_to 
    end
  end
def good_param
    params.require(:good).permit(:good_name, :good_product_num, :good_tag_price, images_attributes: [:id, :avatar, :_destroy])
  end
view 中
<%=f.fields_for :images do |images_form|%>
    <div class="form-group col-sm-3">
      <%= images_form.file_field :avatar, class: 'form-control' %>
      <div class="radio">
        <label>
          <%= images_form.radio_button :is_index, true %>
          设为封面
        </label>
      </div>
      <%= images_form.link_to_remove '删除' %>
    </div>
  <% end %>
  <div class="form-group">
    <%= f.link_to_add '+添加一个背景图', :images, class: 'col-sm-12' %>
 </div>
其中就是我把多态需要用的字段误以为是上传图片的字段,所以会出错。
@saiga 进行 migrate 了。不然怎么会有未知属性呢。
@Yunfei1982 我是嘉定附近的。