Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Gerry
@gerry1004
Member
NO. 15774 / 2014-11-05

上海
13 Topics / 87 Replies
1 Followers
15 Following
68 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 用 Rails 写了一个应用大家看看有价值么? at January 22, 2015

    牛。试了一下。

  • Ubuntu 下搭建 Ruby On Rails 开发环境 at January 22, 2015

    @bluesky329 https://ruby-china.org/wiki/install_ruby_guide

  • Ubuntu 下搭建 Ruby On Rails 开发环境 at January 22, 2015

    前同事的贴,顶顶顶

  • 大家都是如何学习 Rails 开发的 at January 14, 2015

    @rails_on_ll 我的计划已经排满了。哦嚯嚯

  • 转让一台 MacBook Pro at January 14, 2015

    @small_fish__ 3Q,我一开始找到 php 的 Base64_decode 上去了。- - ||。但是不会 PHP

  • 大家都是如何学习 Rails 开发的 at January 14, 2015

    http://segmentfault.com/q/1010000000469766

    感谢@nightire 大神

  • rails 中如何创建相关联的下拉菜单? at January 14, 2015

    用 ajax 做上去。

  • 转让一台 MacBook Pro at January 14, 2015

    @martin 这联系地址,我注意很久了。

  • 转让一台 MacBook Pro at January 13, 2015

    @martin 在魔都,我一直在寻找 MAC,一直被贫穷压着。(摩擦~摩擦)

  • 经验贴:作为程序员,我是怎么月薪 3W 的 at January 07, 2015

    @gsky () /oo\______ \ / ---\ \/ / \ \ \|__\_|/ * || YY|
    || ||

  • 经验贴:作为程序员,我是怎么月薪 3W 的 at December 26, 2014

    膜拜楼主神结尾,突然发现偶好纯洁。

  • 关于多选数据修改 at December 18, 2014

    这孩子肯定没好好学语文!

  • 为什么感觉 Ruby China 里的程序员,基本上是做 Web 的? at December 17, 2014

    我是打杂加写代码的。

  • rails4 + paperclip + nested_form 中发生的错误。 at December 08, 2014

    可以结贴了。。。。

  • rails4 + paperclip + nested_form 中发生的错误。 at December 08, 2014

    找到错误了。我在 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>
    

    其中就是我把多态需要用的字段误以为是上传图片的字段,所以会出错。

  • rails4 + paperclip + nested_form 中发生的错误。 at December 08, 2014

    @saiga 进行 migrate 了。不然怎么会有未知属性呢。

  • [上海] 我们在寻觅上海、嘉定、安亭附近的小伙伴 at November 07, 2014

    @Yunfei1982 我是嘉定附近的。

  • Prev
  • 1
  • 2
  • 3
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English