Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
yeh kevin
@yeyong14
会员
第 5599 位会员 / 2013-02-04

[email protected]
上海
40 篇帖子 / 117 条回帖
3 关注者
8 正在关注
61 收藏
忘记背后,努力面前
GitHub Public Repos
More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 问一个新手提取文件名的问题 at 2014年02月18日

    @cassiuschen 怎么写的吗

  • 一台 nginx 主机多个站点。修改怎么重启其中一个站点 at 2014年02月08日

    @wikimo 是修改网站修改。

  • [已经解决] has_many netsed_form 中模型迭代的问题 at 2014年01月14日

    @yuan 大师,有一个新手问题烦请看下。在collection_select中怎么获取selected 关系是这样的

    #category
    has_many tags
    #tag
    has_many products
    #product
    belongs_to tag
    

    现在想在products/edit中看到之前选过的值。

    <%= form_for @product |f| %>
    #
    #
    <%= collection_select(:tag. :category_id, Category.all, :id, :name, {selected: Category.all.map{|cate| [cate.id, cate.name]}}) %>
    <!-- 这样就全部选上了-->
    <%= grouped_collection_select(:product, :tag_id, Category.all, :tags, :id, :id, :name) %>
    <!--这个grouped_collection_select有selected. -->
    
  • [已经解决] has_many netsed_form 中模型迭代的问题 at 2014年01月13日

    @yuan 谢谢大师!

  • [已经解决] has_many netsed_form 中模型迭代的问题 at 2014年01月13日

    @yuan 好了。非常感谢

    <% photo = photo_fields.object %>
    

    这个是什么意思

  • [已经解决] has_many netsed_form 中模型迭代的问题 at 2014年01月13日

    有谁帮忙看一下吗

  • rails_kineditor route error at 2014年01月08日

    @Martin91 我也没有怎么改,只是按照 README 上面配置的 我是在按照github这里配置的

  • rails_kineditor route error at 2014年01月07日

    @Martin91 已经这样改了还是这样

  • 多个模型嵌套,will_paginate 怎么分页 at 2013年12月30日

    @lufeihaidao

    @tag = @category.tags.find(params[:id])
    

    Couldn't find Tag with id=1 [WHEREtags.category_id= 1]

  • 多个模型嵌套,will_paginate 怎么分页 at 2013年12月30日

    @lufeihaidao 不是很了解。怎么写的

  • number_file_tag 怎么动态的添加进数据库 at 2013年12月26日

    @shooter
    [email protected]

  • number_file_tag 怎么动态的添加进数据库 at 2013年12月26日

    @shooter 这个要如何做,能否举个例子

  • number_file_tag 怎么动态的添加进数据库 at 2013年12月26日

    @shooter 参照敏捷开发 4 上面的,购物车情况,想在cart里面直接修改line_item中quantity值。然后在 order 获取这个修改的值

  • number_file_tag 怎么动态的添加进数据库 at 2013年12月26日

    @shooter

    <table class="table">
    @cart.line_items.each do |item| %>
    <tr>
    <td><%= item.product.title %></td>
    <td><%= number_field_tag item.quantity, item.quantity,min: 1, max: 10 %>
    </tr>
    <% end %>
    </table>
      <%= button_to "checkout", new_order_path, method: :get %>
    
  • number_file_tag 怎么动态的添加进数据库 at 2013年12月26日

    @shooter 能不能详细点。给个思路,我是新手

  • Rails 数据库查询 joins 数据重复的问题 at 2013年12月24日

    @Rei 谢谢。搞定!

  • 多个模型嵌套,数据关联的问题 at 2013年12月20日

    @blueplanet 看的好仔细啊。打错了。rails 版本是 3.2.13

  • 多个模型嵌套,数据关联的问题 at 2013年12月20日

    @Martin91 我没有 model 加验证机制,保存都是成功的。只是在@line_item中没有添加 numbers_id. 我想在 line_item 的控制中,定义当添加进购物车的内容也同时添加 number_id,.这个有没有思路要怎么添加。像我在 create 中添加的

    def create
      @product = Product_find(params[:product_id])
      @line_item = @cart.add_product(product.id)
      @line = @product.line_items.new(parms[:line_item])
      if @line_item.save && @line.save
        redirect_to cart_path
      end
    end
    

    这样就有二个 line_item 同时加进来,而且其中的一个没有 cart_id 是空的,不知道你有好的思路吗 在 cart 的模型中可以加的吗?

    def add_product(product_id)
      current_item = line_items.find_by_product_id(product_id)
      if current_item
         current_item.quantity +=1
       else 
         current_item = line_items.build(product_id: product_id)
      end
      current_item
    end
    

    能给个思路要怎么加的吗

  • 多个模型嵌套,数据关联的问题 at 2013年12月20日

    @Martin91 帮忙看看吧

  • Rails check_box 如何使用 at 2013年12月11日

    @ericguo undefined method `collection_check_boxes' for #NestedForm::Builder:0x922fbc4

  • Rails check_box 如何使用 at 2013年12月10日

    @ericguo 我的是 rails 3.2.13

  • 「已经解决」怎么撤销 git checkout -f origin/master at 2013年12月06日

    @xds2000 谢谢,搞定了

  • 分享一本 Rails 的新书《learn-ruby-on-rails》 at 2013年11月30日

    全英文的啊

  • Ruby Programming 第 11 章练习第 9 题不会,请教高手指点 at 2013年11月28日

    可以

  • 关于 build 的问题 at 2013年11月26日

    @song940 现在出现了这个错误

    ActiveModel::MassAssignmentSecurity::Error in ProductsController#update
    
    Can't mass-assign protected attributes: product
    
  • 关于 build 的问题 at 2013年11月26日

    @song940 @Martin91 控制器报错的位置

    app/controllers/products_controller.rb:61:in `block in update'
    app/controllers/products_controller.rb:60:in `update'
    
    #controller
    def update
      @product = Product.find(params[:id])
      if @product.update_attributes(params[:product])
       redirect_to @product
      else 
       render 'edit'
    end
    
  • 关于 build 的问题 at 2013年11月26日

    @song940 @Martin91我按照你给博客地址配置了可以动态添加项目。就是更新的时候出现了这个错误

    NoMethodError in ProductsController#update
    
    undefined method `file_changed?' for #<Photo:0xb5eee250>
    

    当 photos 为空的时候。能正常更新。当有项目的时候就报上面的错。

  • 关于 build 的问题 at 2013年11月25日

    @song940 谢谢。刚刚是看到你的帖子,我正在试

  • 关于 build 的问题 at 2013年11月25日

    @Martin91

    #控制器
    def new
        @product = Product.new
                    8.times{@product.pictures.build}
                    @product.videos.build
    end
    
    #View
    
    <%= form_for(@product, html: {multipart: true}) do |f| %>
    <div class="field">
                    <%= f.fields_for :pictures do |pic| %>
                            <%= pic.label :imag %>
                            <%= pic.file_field :image %>
                    <% end %>
      </div>
    <% end %>
    
  • 单页面嵌套 form 如何实现,js & gem at 2013年11月25日

    回复错了

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