<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>zjnxzy (白板)</title>
    <link>https://ruby-china.org/zjnxzy</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>将本地 rails 项目部署到 VM 的 cloudfoundry 中出现的错误</title>
      <description>&lt;p&gt;先说下应用的开发环境：ruby1.9.3，rails3.2.9，mongodb2.2 在 window 环境下开发的，并且在本地电脑下运行时没有问题，部署到 VM 的 cloudfoundry 中就出现找不到页面，查看日志时发现如下问题：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No Redis service bound to app.  Skipping auto-reconfiguration.
Loading MongoDB auto-reconfiguration.
No MongoDB Library Found. Skipping auto-reconfiguration.
No MySQL service bound to app.  Skipping auto-reconfiguration.
No PostgreSQL service bound to app.  Skipping auto-reconfiguration.
No RabbitMQ service bound to app.  Skipping auto-reconfiguration.
=&amp;gt; Booting WEBrick
=&amp;gt; Rails 3.2.9 application starting in production on http://0.0.0.0:8345
=&amp;gt; Call with -d to detach
=&amp;gt; Ctrl-C to shutdown server
Started GET "/" for 183.233.189.114 at 2013-04-18 02:21:42 +0000
Connecting to database specified by database.yml
Processing by ArticlesController#index as HTML
  Rendered articles/index.html.erb within layouts/application (90.5ms)
Completed 500 Internal Server Error in 144ms

ActionView::Template::Error (
Problem:
  No sessions configuration provided.
Summary:
  Mongoid's configuration requires that you provide details about each session t
hat can be connected to, and requires in the sessions config at least 1 default
session to exist.
Resolution:
  Double check your mongoid.yml to make sure that you have a top-level sessions
key with at least 1 default session configuration for it. You can regenerate a n
ew mongoid.yml for assistance via `rails g mongoid:config`.

 Example:
 \_\_development:
 \_\_\_\_sessions:
 \_\_\_\_\_\_default:
 \_\_\_\_\_\_\_\_database: mongoid_dev
 \_\_\_\_\_\_\_\_hosts:
 \_\_\_\_\_\_\_\_\_\_- localhost:27017
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但是所说的 mongoid.yml 配置，我是已经配置好的，配置如下：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;development:
  # Configure available database sessions. (required)
  sessions:
    # Defines the default session. (required)
    default:
      # Defines the name of the default database that Mongoid can connect to.
      # (required).
      database: spec_mongoid_development
      # Provides the hosts the default session can connect to. Must be an array
      # of host:port pairs. (required)
      hosts:
        - localhost:27017
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;求在 VM 的 cloudfoundry 部署成功过的朋友给建议。。。。谢谢啦&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Thu, 18 Apr 2013 10:51:02 +0800</pubDate>
      <link>https://ruby-china.org/topics/10298</link>
      <guid>https://ruby-china.org/topics/10298</guid>
    </item>
    <item>
      <title>Rails 的中 CoffeeScript 的使用问题</title>
      <description>&lt;p&gt;以前一种使用的是 Jquery，因为 rails 默认使用的是 coffeeScript，所以该学习 coffeescript，但是遇到下面的问题，希望得到解答。
    建立一个 rails 工程，生成一个 welcome 的控制器，然后也就生成了一个 welcome.js.coffee 的文件。
    然后在 welcome.js.coffee 写 coffeescript 代码，也一般的 coffee 代码都有用，比如说弹出框：alert“hello”，但是当写下面代码时，去没有效果了：&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcd = (a,b) -&amp;gt; if (b==0) then a else gcd(b, a % b)&lt;/code&gt;
  &lt;code&gt;$("#button").click -&amp;gt;&lt;/code&gt;
          &lt;code&gt;a = $("#a").val()&lt;/code&gt;
         &lt;code&gt;b = $("#b").val()&lt;/code&gt;
         &lt;code&gt;$("#c").html gcd(a,b)&lt;/code&gt;
备注，不知道怎么缩进代码，后面三行有缩进的。
页面上的代码：
 &lt;code&gt;A: &amp;lt;input type="text" id="a"/&amp;gt;&amp;lt;br/&amp;gt;
 B: &amp;lt;input type="text" id="b"/&amp;gt;&amp;lt;br/&amp;gt;
 &amp;lt;input type="button" value="Calculate GCD" id="button"/&amp;gt; &amp;lt;br/&amp;gt;&lt;/code&gt;
&lt;code&gt;C: &amp;lt;span id="c"/&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;发生的情况就是单击按钮事件没有反应，我是在 window 环境下测试的，rails3.2.9.
求解答是什么原因。。。。。&lt;/p&gt;

&lt;p&gt;补充：后面发现好像是 Jquery 无法使用，但是我不知道为什么 jquery 为什么不能使用，我是一个新建的 rails 项目，什么都没有改，在 application.html.erb 页面中的 head 中用下面的测试代码：
&lt;code&gt;
    &amp;lt;script type="text/javascript"&amp;gt;
    $('#b').click(function(){
        alert("hello");
    });
  &amp;lt;/script&amp;gt;
&lt;/code&gt;
发现没有任何反应，求解是什么原因？&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Tue, 09 Apr 2013 14:44:04 +0800</pubDate>
      <link>https://ruby-china.org/topics/10040</link>
      <guid>https://ruby-china.org/topics/10040</guid>
    </item>
    <item>
      <title>rails 遇到的一个小问题，记录一下以便不时之需</title>
      <description>&lt;p&gt;在使用 rails 中的 Ajax 时，如果想要替换页面的数值时，如下代码所示：
&lt;code&gt;$("#sell_money").html("￥ &amp;lt;%=j @sell_money %&amp;gt;")&lt;/code&gt;其中&lt;a href="/sell_money" class="user-mention" title="@sell_money"&gt;&lt;i&gt;@&lt;/i&gt;sell_money&lt;/a&gt;是后台查出的销售金额，是一个浮点型的数值，#sell_money 表示的是页面上的一个 &lt;span&gt;标签。
这样会出现以下错误：
     undefined method &lt;code&gt;gsub' for 。。。。
具体改正如下：
  将&lt;/code&gt;$("#sell_money").html("￥ &amp;lt;%=j &lt;a href="/sell_money" class="user-mention" title="@sell_money"&gt;&lt;i&gt;@&lt;/i&gt;sell_money&lt;/a&gt; %&amp;gt;") &lt;code&gt;替换成                                                 
&lt;/code&gt;$("#sell_money").html("￥ &amp;lt;%=j &lt;a href="/sell_money.to_s" class="user-mention" title="@sell_money.to_s"&gt;&lt;i&gt;@&lt;/i&gt;sell_money.to_s&lt;/a&gt; %&amp;gt;") `&lt;/span&gt;&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Fri, 15 Mar 2013 10:29:02 +0800</pubDate>
      <link>https://ruby-china.org/topics/9443</link>
      <guid>https://ruby-china.org/topics/9443</guid>
    </item>
    <item>
      <title>Jquery 的一个问题</title>
      <description>&lt;p&gt;不知道在这里怎么格式化代码，只能用图片了，代码如下图：&lt;img src="//l.ruby-china.com/photo/22452434e8d6dd6f5cfb1b1877f5f9d3.png" title="" alt=""&gt;
页面上代码如下图：&lt;img src="//l.ruby-china.com/photo/9237b797ca0dd8286dba643811eef608.png" title="" alt=""&gt;
主要实现的功能是，单击那个“上传图片”按钮后会出现一个上传图片的框。然后使用 Ajax 上传图片。但是出现以下结果：
 第一次，上传了图片。
上传完第一次后，接着上传第二张图片，这个时候，第二张图片会被上传两次，在服务器上存在两张同样的第二张图片。
上传完第二张图片后，上传第三张图片，这个时候第三张图片被上传了三次。
。。。。
请问这是什么情况呀，我的 js 代码哪里出现了问题。。。。&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Wed, 13 Mar 2013 22:37:43 +0800</pubDate>
      <link>https://ruby-china.org/topics/9394</link>
      <guid>https://ruby-china.org/topics/9394</guid>
    </item>
    <item>
      <title>ruby-china 发表帖子的功能一些问题？</title>
      <description>&lt;p&gt;（1）ruby-china 这个“新建帖子”功能使用的是什么编辑器呀？
（2）右上角那个上传图片的功能是怎么实现的呀？看源代码没有看懂。。。
（3）预览功能是怎么实现的呀？看源代码还是没看懂。。。
求知情人士教下我，不胜感激。。。。
附代码图片一张：&lt;img src="//l.ruby-china.com/photo/1e148a6cd7a80befba0148ec511bccac.png" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Tue, 12 Mar 2013 20:39:35 +0800</pubDate>
      <link>https://ruby-china.org/topics/9364</link>
      <guid>https://ruby-china.org/topics/9364</guid>
    </item>
    <item>
      <title>验证 github 的 SSH 问题</title>
      <description>&lt;p&gt;我按照&lt;a href="https://help.github.com/articles/generating-ssh-keys" rel="nofollow" target="_blank"&gt;https://help.github.com/articles/generating-ssh-keys&lt;/a&gt; &lt;img src="//l.ruby-china.com/photo/97b2ce4d077abea45675a3b965145fa0.png" title="" alt=""&gt;
方法来生成了 SSH 的 private key 和 public key 但是到了第五步 Test everything out 时总是出现图片上的问题，但是我确定 passphrase 输入是没有问题的。
我的电脑操作系统是 windows7.
请您们帮忙看看怎么解决？我需要是 heroku，就是这个 SSH 的问题，弄了一天了，还是没解决。。。。&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Sun, 10 Mar 2013 11:51:07 +0800</pubDate>
      <link>https://ruby-china.org/topics/9294</link>
      <guid>https://ruby-china.org/topics/9294</guid>
    </item>
    <item>
      <title>有关 bootstrap 框架的问题</title>
      <description>&lt;p&gt;我在项目中使用的是 anjlab-bootstrap-rails 的 gem，如果我在 application.html.erb 中按下面配置：&lt;/p&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;stylesheet_link_tag&lt;/span&gt;    &lt;span class="s2"&gt;"application"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:media&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"all"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;javascript_include_tag&lt;/span&gt; &lt;span class="s2"&gt;"application"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;可以将 bootstrap 的 css 和 js 加载进来，但是同时也将很多不需要的 js 和 css 文件加载进来了。
 有什么方法可以只加载 bootstrap 的 css 和 js，and 自己需要的 js 和 css 文件。
这种方式：&lt;/p&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;stylesheet_link_tag&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:controller&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="ss"&gt;:media&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"all"&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;javascript_include_tag&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:controller&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;只能加载对应 controller 的 css 和 js，不能加载 bootstrap 的。&lt;/p&gt;

&lt;p&gt;求解决的办法呀，急用，嘿嘿！&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Tue, 05 Mar 2013 11:39:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/9134</link>
      <guid>https://ruby-china.org/topics/9134</guid>
    </item>
    <item>
      <title>使用 anjlab-bootstrap-rails 时，无法加载 css 样式</title>
      <description>&lt;p&gt;我在使用 anjlab-bootstrap-rails 时，在 app/assets/stylesheets/application.css 中加入了*= require twitter/bootstrap，但是样式还是在浏览器中浏览是还是无法看到样式。这是什么原因呢？求解答，急用哦！&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Thu, 28 Feb 2013 10:56:57 +0800</pubDate>
      <link>https://ruby-china.org/topics/9002</link>
      <guid>https://ruby-china.org/topics/9002</guid>
    </item>
    <item>
      <title>安装 ruby-china 源码时，pygments 安不上，求解答。。。谢谢</title>
      <description>&lt;p&gt;在本地部署 ruby-china 时，其他的必要条件都安装好了，就是 pygments 安装不上
我安装的方法如下：
zjnxyz@zjnxyz-VirtualBox:~$ sudo easy_install pygments
Searching for pygments
Reading &lt;a href="http://pypi.python.org/simple/pygments/" rel="nofollow" target="_blank"&gt;http://pypi.python.org/simple/pygments/&lt;/a&gt;
Reading &lt;a href="http://pygments.org/" rel="nofollow" target="_blank"&gt;http://pygments.org/&lt;/a&gt;
Reading &lt;a href="http://pygments.pocoo.org/" rel="nofollow" target="_blank"&gt;http://pygments.pocoo.org/&lt;/a&gt;
Best match: Pygments 1.6
Downloading &lt;a href="http://pypi.python.org/packages/2.7/P/Pygments/Pygments-1.6-py2.7.egg#md5=1e1e52b1e434502682aab08938163034" rel="nofollow" target="_blank"&gt;http://pypi.python.org/packages/2.7/P/Pygments/Pygments-1.6-py2.7.egg#md5=1e1e52b1e434502682aab08938163034&lt;/a&gt;
error: None
PS：我是使用的系统是 ubuntu12.0.10。。。。。。
求解答呀。。。。&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Sat, 09 Feb 2013 14:53:19 +0800</pubDate>
      <link>https://ruby-china.org/topics/8657</link>
      <guid>https://ruby-china.org/topics/8657</guid>
    </item>
    <item>
      <title>rails 使用生成的 destroy 方法时，为什么同时还会将 session 中的数据销毁了？</title>
      <description>&lt;p&gt;今天在使用 rails 开发时，使用 rake 生产的增删改查方法，发现使用 destroy 方法（删除一条数据）时，会将保存在 session 中的用户信息也一起销毁了，不知道是什么原因。。。。&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Sat, 02 Feb 2013 19:08:55 +0800</pubDate>
      <link>https://ruby-china.org/topics/8569</link>
      <guid>https://ruby-china.org/topics/8569</guid>
    </item>
    <item>
      <title>rails 如何根据需要来加载 css 和 js 文件呀？</title>
      <description>&lt;p&gt;在 rails 项目中将 css 文件和 js 文件放在 assets 相应文件夹中，就可以自动的加载到页面中，但是这样所有的页面都加载了这些文件，这样好像加载速度有些慢，并且不同的前端框架的 css 文件存在一定的冲突。因为，我如何在页面上按照自己的需要来加载这些 css 和 js 文件呢？
    求回答，急用。。。。。
     谢谢啦。。。。。&lt;/p&gt;</description>
      <author>zjnxzy</author>
      <pubDate>Tue, 22 Jan 2013 11:46:27 +0800</pubDate>
      <link>https://ruby-china.org/topics/8255</link>
      <guid>https://ruby-china.org/topics/8255</guid>
    </item>
  </channel>
</rss>
