<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>mlb0903 (马立斌)</title>
    <link>https://ruby-china.org/mlb0903</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>关于生成静态的 html 页面 并保存下来</title>
      <description>&lt;p&gt;各位大侠 学习 ROR 时间不长，现在在做一个系统，从数据库动态加载出一个页面，我想把这个页面保存下来，并可以提供下载操作，现在没有一点想法，大侠们有没有什么好的建议，或者什么参考之类的！&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Fri, 20 Dec 2013 15:41:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/16339</link>
      <guid>https://ruby-china.org/topics/16339</guid>
    </item>
    <item>
      <title>关于文件上传</title>
      <description>&lt;p&gt;1、问题代码
  views :&lt;br&gt;
     &amp;lt;%= file_field_tag "attachment", :accept =&amp;gt; 'application/msexcel'%&amp;gt;
  controller:
     att_file = params[:attachment].read
     att_file_name = params[:attachment].original_filename
     File.open("public/attachment_file", "wb") do |f|
        f.write(xx)
     end
2、问题
    Permission denied - public/attachment_file&lt;/p&gt;

&lt;p&gt;第一次做这种关于文件上传，不太知道这类错误的原因，还请大家帮忙~！！！&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Wed, 04 Dec 2013 20:11:22 +0800</pubDate>
      <link>https://ruby-china.org/topics/16009</link>
      <guid>https://ruby-china.org/topics/16009</guid>
    </item>
    <item>
      <title>问各位一个关于数组的全排列的问题</title>
      <description>&lt;p&gt;条件：现在有这样一个数组 [[2,3],[4,5],[6,7],……]，小数组中的元素个数不一定是两个元素，它的个数也是不定的。
需求：最后要得到这样一个类似这样的数组 [[2,4,6],[2,4,7],[2,5,6],[2,5,7],……]
我的后台 ruby 代码该怎么写？自己学习 ruby 时间不长，感觉有点混乱。。。&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Mon, 28 Oct 2013 16:02:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/15092</link>
      <guid>https://ruby-china.org/topics/15092</guid>
    </item>
    <item>
      <title>Windows 上面 SQLite  gem 包安装不上怎么解决？</title>
      <description>&lt;p&gt;&lt;img src="//l.ruby-china.com/photo/62f4e9c267a8af970185677a5bc69571.jpg" title="" alt=""&gt;
这个是什么原因？&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Thu, 26 Sep 2013 11:40:36 +0800</pubDate>
      <link>https://ruby-china.org/topics/14402</link>
      <guid>https://ruby-china.org/topics/14402</guid>
    </item>
    <item>
      <title>求推荐个苹果笔记本</title>
      <description>&lt;p&gt;最近一同学要出国，想要买一台苹果笔记本，但是本人就是一屌丝，现在没有这个经济实力，所以对苹果一点研究都没有，还请各位推荐推荐。主要就是用来做设计，多用来处理图片跑 PS、3D Max 以及 maya 这些，对内存和显卡的要求可能高一点。谢谢各位了。&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Thu, 26 Sep 2013 10:51:59 +0800</pubDate>
      <link>https://ruby-china.org/topics/14401</link>
      <guid>https://ruby-china.org/topics/14401</guid>
    </item>
    <item>
      <title>关于统计在线人数</title>
      <description>&lt;p&gt;我现在用户是通过 session[:user_id]=user.id 来保存的，我现在想统计在线人数有没有什么简单的方法，还请各位指教。&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Thu, 15 Aug 2013 17:36:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/13356</link>
      <guid>https://ruby-china.org/topics/13356</guid>
    </item>
    <item>
      <title>求好用得日历插件</title>
      <description>&lt;p&gt;最近一段时间要做一个智能会议室预约系统，关于日历的设计想用一个日历的插件，各位前辈都知道那些好用的日历插件，推荐推荐。
具体想做成一下这种格式：&lt;img src="//l.ruby-china.com/photo/0ac92e88782c0a5d0a6ad09f8486a93c.png" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;还有模仿过谷歌日历的写法，关于前端的一些实现自己还有一些疑惑。谢谢各位了！！！&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Tue, 06 Aug 2013 11:09:31 +0800</pubDate>
      <link>https://ruby-china.org/topics/13089</link>
      <guid>https://ruby-china.org/topics/13089</guid>
    </item>
    <item>
      <title>关于 Git</title>
      <description>&lt;p&gt;在安装完成 Git 以及 TortoiseGit 后，获得了 key 并且在 github 上的 SSH Key 中也进行了设置，但是在 Clone 的时候遇到以下错误，求有各位有经验的指导以下，小弟先谢过了。以下是错误的截图：&lt;img src="//l.ruby-china.com/photo/2bc284008f4f7acfbcb25e16cd74971b.png" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Sun, 04 Aug 2013 10:35:59 +0800</pubDate>
      <link>https://ruby-china.org/topics/13034</link>
      <guid>https://ruby-china.org/topics/13034</guid>
    </item>
    <item>
      <title>求帮助！！！</title>
      <description>&lt;p&gt;谁有比完整的关于介绍 ROR 的相关外文文档，借我用用，毕业设计用外文翻译资料，不知道去哪里找，网站找到的不是嵌入的代码太多，就是已经有人翻译过了不敢用，小弟先在这里谢过了啊&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Thu, 02 May 2013 11:37:13 +0800</pubDate>
      <link>https://ruby-china.org/topics/10648</link>
      <guid>https://ruby-china.org/topics/10648</guid>
    </item>
    <item>
      <title>想做一个购物网站的购物车，结果一天没有搞出来</title>
      <description>&lt;p&gt;疑问：只有用户登陆以后才能购物，每个用户关联自己的购物车，相同用户再次登录以后购物车里边的物品还在。在做的过程中总是遇到很多问题不知道怎么去解决。
谁能说说这样一种情况，我该怎么设计数据库和 carts_controller 呢？&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Thu, 14 Mar 2013 18:00:36 +0800</pubDate>
      <link>https://ruby-china.org/topics/9423</link>
      <guid>https://ruby-china.org/topics/9423</guid>
    </item>
    <item>
      <title>关于购物车的一个问题，请前辈们指教！</title>
      <description>&lt;p&gt;这是遇到的错误，找了好久没找到问题出在什么地方。
NoMethodError in StoreController#add_to_cart&lt;/p&gt;

&lt;p&gt;undefined method `product' for #&lt;a rel="nofollow" target="_blank"&gt;Product:0xaa46858&lt;/a&gt;
Rails.root: C:/Users/malibin/My Documents/Aptana Studio 3 Workspace/shopMe&lt;/p&gt;

&lt;p&gt;Application Trace | Framework Trace | Full Trace
app/models/cart.rb:9:in &lt;code&gt;add_product'
app/models/cart.rb:9:in&lt;/code&gt;each'
app/models/cart.rb:9:in &lt;code&gt;find'
app/models/cart.rb:9:in&lt;/code&gt;add_product'
app/controllers/store_controller.rb:9:in `add_to_cart'&lt;/p&gt;

&lt;p&gt;这是我的 controller 和 model
class Cart 
  attr_reader :items&lt;br&gt;
  def initialize
    &lt;a href="/items" class="user-mention" title="@items"&gt;&lt;i&gt;@&lt;/i&gt;items&lt;/a&gt; = []
  end&lt;br&gt;
  def add_product(product)
    current_item = &lt;a href="/items.find" class="user-mention" title="@items.find"&gt;&lt;i&gt;@&lt;/i&gt;items.find&lt;/a&gt; {|item| item.product == product}
    if current_item
      current_item.increment_quantity
    else
      current_item = CartItem.new(product)
      &lt;a href="/items" class="user-mention" title="@items"&gt;&lt;i&gt;@&lt;/i&gt;items&lt;/a&gt; &amp;lt;&amp;lt; current_item
    end
    current_item
  end&lt;br&gt;
  def total_price
    &lt;a href="/items.sum" class="user-mention" title="@items.sum"&gt;&lt;i&gt;@&lt;/i&gt;items.sum&lt;/a&gt; { |item| item.price }
  end&lt;br&gt;
  def total_items
    &lt;a href="/items.sum" class="user-mention" title="@items.sum"&gt;&lt;i&gt;@&lt;/i&gt;items.sum&lt;/a&gt; { |item| item.quantity }
  end&lt;br&gt;
  def total_price
    &lt;a href="/items.sum" class="user-mention" title="@items.sum"&gt;&lt;i&gt;@&lt;/i&gt;items.sum&lt;/a&gt; { |item| item.price }
  end&lt;br&gt;
end &lt;/p&gt;

&lt;p&gt;class StoreController &amp;lt; ApplicationController
  def index
    &lt;a href="/products" class="user-mention" title="@products"&gt;&lt;i&gt;@&lt;/i&gt;products&lt;/a&gt; = Product.find_product_for_sale
  end&lt;/p&gt;

&lt;p&gt;def add_to_cart
    product = Product.find(params[:id])
    &lt;a href="/cart" class="user-mention" title="@cart"&gt;&lt;i&gt;@&lt;/i&gt;cart&lt;/a&gt; = find_cart
    &lt;a href="/cart.add_product" class="user-mention" title="@cart.add_product"&gt;&lt;i&gt;@&lt;/i&gt;cart.add_product&lt;/a&gt;(product)
  rescue ActiveRecord::RecordNotFound
    logger.error("Attempt to access invalid product #{params[:id]}" )
    flash[:notice] = "Invalid product"
    redirect_to :action =&amp;gt; 'index'
  end&lt;/p&gt;

&lt;p&gt;def find_cart
    unless session[:cart]           # if there's no cart in the session
    session[:cart] = Cart.new    # add a new one
  end
    session[:cart]                   # return existing or new cart
  end
  #清空购物车
  def empty_cart
    session[:cart] = nil
    flash[:notice] = "Your cart is currently empty"
    redirect_to :action =&amp;gt; 'index'
  end&lt;/p&gt;

&lt;p&gt;end&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Tue, 12 Mar 2013 11:36:41 +0800</pubDate>
      <link>https://ruby-china.org/topics/9347</link>
      <guid>https://ruby-china.org/topics/9347</guid>
    </item>
    <item>
      <title>问大家一个基础的问题啊，一直没有搞清楚</title>
      <description>&lt;p&gt;Active Record 支持的数据类型中：date、datetime、time 有什么区别？&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Wed, 23 Jan 2013 10:34:44 +0800</pubDate>
      <link>https://ruby-china.org/topics/8287</link>
      <guid>https://ruby-china.org/topics/8287</guid>
    </item>
    <item>
      <title>用 Spreadsheet 这个 gem 包来操作 Excel 是不是不能实现横竖单元格的合并？？？</title>
      <description>&lt;p&gt;最近公司安排做这个调查，用这个 gem 包怎么都没有办法实现单元格的合并，我就想知道用这个 gem 包是不是没有办法实现？&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Wed, 16 Jan 2013 10:27:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/8104</link>
      <guid>https://ruby-china.org/topics/8104</guid>
    </item>
    <item>
      <title>想用 Rails 来做一个简单的购物网站，有什么建议</title>
      <description>&lt;p&gt;想用 Rails 来做一个简单的购物网站，大家有什么建议，或者说有已经做好的我参考一下。&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Mon, 14 Jan 2013 17:10:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/8062</link>
      <guid>https://ruby-china.org/topics/8062</guid>
    </item>
    <item>
      <title>这是一个什么错误，找了都快半天但就是不知道哪儿错了</title>
      <description>&lt;p&gt;&lt;img src="//l.ruby-china.com/photo/c0232432a53e0394731f1cdfe4645167.png" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Mon, 14 Jan 2013 13:19:08 +0800</pubDate>
      <link>https://ruby-china.org/topics/8051</link>
      <guid>https://ruby-china.org/topics/8051</guid>
    </item>
    <item>
      <title>请教各位</title>
      <description>&lt;p&gt;rake db:migrate RAILS_ENV=production。这句话的作用是什么，在什么情况下用，有点不太理解。&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Sun, 13 Jan 2013 20:58:22 +0800</pubDate>
      <link>https://ruby-china.org/topics/8034</link>
      <guid>https://ruby-china.org/topics/8034</guid>
    </item>
    <item>
      <title>想找个师傅</title>
      <description>&lt;p&gt;学习 rails 半个月时间，遇到很多问题不知道怎么解决，痛苦啊，很想找个师傅……&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Fri, 11 Jan 2013 09:09:26 +0800</pubDate>
      <link>https://ruby-china.org/topics/7967</link>
      <guid>https://ruby-china.org/topics/7967</guid>
    </item>
    <item>
      <title>Ruby 操作 excel</title>
      <description>&lt;p&gt;最近这段时间一直在学习用 Ruby 来操作 excel，遇到了很多问题，我使用的是 spreadsheet，但是在网上根本找不到多少资料，只有一个简单的 GUIDE.txt，让人很痛苦，那个师兄有这方便面的资料能跟我分享一下吗，感激不尽啊&lt;/p&gt;</description>
      <author>mlb0903</author>
      <pubDate>Wed, 09 Jan 2013 09:06:40 +0800</pubDate>
      <link>https://ruby-china.org/topics/7896</link>
      <guid>https://ruby-china.org/topics/7896</guid>
    </item>
  </channel>
</rss>
