<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>#raynix# &#187; ruby on rails</title>
	<atom:link href="http://raynix.info/archives/tag/ruby-on-rails/feed" rel="self" type="application/rss+xml" />
	<link>http://raynix.info</link>
	<description>When others see chance, I see cause.</description>
	<lastBuildDate>Thu, 09 Sep 2010 04:40:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>做了一个简单的报表软件</title>
		<link>http://raynix.info/archives/120</link>
		<comments>http://raynix.info/archives/120#comments</comments>
		<pubDate>Mon, 11 Jun 2007 08:42:04 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Opensource]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://raynix.cn/archives/120</guid>
		<description><![CDATA[报表选项页和项目清单页： 生成报表结果（使用Gruff Graph做的） 呵呵，rails还是很好玩的。这个软件虽然很简单，但是已经能代替很多Excel功能了，而且可以多人协作。继续努力。 © raynix for #raynix#, 2007. &#124; Permalink &#124; 3 条评论 &#124; Add to del.icio.us Post tags: ruby on rails Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p>报表选项页和项目清单页：<br />
<a href="http://raynix.info/wp-content/uploads/2007/06/charting1.png" title="charting1.png"><img src="http://raynix.info/wp-content/uploads/2007/06/charting1.thumbnail.png" alt="charting1.png" /></a> <a href="http://raynix.info/wp-content/uploads/2007/06/salesmanager03.png" title="salesmanager03.png"><img src="http://raynix.info/wp-content/uploads/2007/06/salesmanager03.thumbnail.png" alt="salesmanager03.png" /></a></p>
<p>生成报表结果（使用<a href="http://nubyonrails.com/pages/gruff" target="_blank">Gruff Graph</a>做的）<br />
<a href="http://raynix.info/wp-content/uploads/2007/06/my_graph.png" title="my_graph.png"><img src="http://raynix.info/wp-content/uploads/2007/06/my_graph.thumbnail.png" alt="my_graph.png" /></a></p>
<p>呵呵，rails还是很好玩的。这个软件虽然很简单，但是已经能代替很多Excel功能了，而且可以多人协作。继续努力。</p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2007. |
<a href="http://raynix.info/archives/120">Permalink</a> |
<a href="http://raynix.info/archives/120#comments">3 条评论</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/120&title=做了一个简单的报表软件">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/ruby-on-rails" rel="tag">ruby on rails</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/120/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>小试rails当中对多重选择表单的处理</title>
		<link>http://raynix.info/archives/98</link>
		<comments>http://raynix.info/archives/98#comments</comments>
		<pubDate>Thu, 17 May 2007 08:23:39 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Opensource]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://raynix.cn/archives/98</guid>
		<description><![CDATA[keys: ruby rails multiple checkbox 今天上班给老板写个项目销售管理的小东西，其中涉及到多重选择的处理。目前感觉rails在这方面相对弱，也许因为rails在其它方面太强了吧。总之，对于用rails处理multiple checkbox，还真需要些基础知识。 例子中的任务是为一个项目project指定人员user_file，这显然是一个N对N（HABTM）的关联，按照David的建议，我把关联表project_user_map也作为实体处理了。 介绍一下模型 model: class Project ... has_many :project_user_maps end class ProjectUserMap belongs_to :project belongs_to :user_file end class UserFile has_many :project_user_maps end 先说view: &#60;% form_tag :action =&#62; 'edit_member_2', :id =&#62; @project do %&#62; &#60;% for user_file in @all%&#62; &#60;%= check_box_tag( 'selected_file_ids[]', user_file.id, @members.include?(user_file))%&#62;&#60;%= user_file.name%&#62; &#60;% end %&#62; &#60;br/&#62; &#60;%= [...]]]></description>
			<content:encoded><![CDATA[<p>keys: ruby rails multiple checkbox</p>
<p>今天上班给老板写个项目销售管理的小东西，其中涉及到多重选择的处理。目前感觉rails在这方面相对弱，也许因为rails在其它方面太强了吧。总之，对于用rails处理multiple checkbox，还真需要些基础知识。</p>
<p>例子中的任务是为一个项目project指定人员user_file，这显然是一个N对N（HABTM）的关联，按照David的建议，我把关联表project_user_map也作为实体处理了。</p>
<p>介绍一下模型 model:</p>
<p>class Project ...<br />
has_many :project_user_maps<br />
end</p>
<p>class ProjectUserMap</p>
<p>belongs_to :project<br />
belongs_to :user_file<br />
end</p>
<p>class UserFile<br />
has_many :project_user_maps<br />
end</p>
<p>先说view:</p>
<p>&lt;% form_tag :action =&gt; 'edit_member_2', :id =&gt; @project do %&gt;<br />
&lt;% for user_file in @all%&gt;<br />
&lt;%= check_box_tag( 'selected_file_ids[]', user_file.id, @members.include?(user_file))%&gt;&lt;%= user_file.name%&gt;<br />
&lt;% end %&gt;<br />
&lt;br/&gt;<br />
&lt;%= submit_tag '完成！' %&gt;<br />
&lt;% end %&gt;</p>
<p>要点是selected_file_ids[]，这样提交以后，rails会生成一个对应的数组。@all是全部可选项；@members是被选中的选项。</p>
<p>然后是controller：</p>
<p>def edit_member_2<br />
@project = Project.find(params[:id])<br />
member_ids = params[:selected_file_ids]<br />
ProjectUserMap.transaction do<br />
@project.project_user_maps.each { |pum|<br />
pum.destroy<br />
}<br />
member_ids.each {|uf|<br />
m = ProjectUserMap.new<br />
m.user_file_id = uf<br />
@project.project_user_maps &lt;&lt; m<br />
m.save()<br />
}<br />
@project.save<br />
end<br />
redirect_to :action =&gt;  'show', :id =&gt; @project<br />
end</p>
<p>这段只能说运行没问题，肯定还有改进余地的:) <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/140430" target="_blank">参考1</a></p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2007. |
<a href="http://raynix.info/archives/98">Permalink</a> |
<a href="http://raynix.info/archives/98#comments">唉, 一个评论都没</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/98&title=小试rails当中对多重选择表单的处理">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/ruby-on-rails" rel="tag">ruby on rails</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/98/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>牛刀小试RegEx</title>
		<link>http://raynix.info/archives/64</link>
		<comments>http://raynix.info/archives/64#comments</comments>
		<pubDate>Fri, 27 Apr 2007 05:45:28 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Opensource]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://raynix.bjqnc.com/archives/64</guid>
		<description><![CDATA[RegEx中文叫做正则表达式，虽然不是很新的东西了，我很纳闷我居然是才开始了解它。在数据库中查询keyword一般是写成 select * from tablename where columnname LIKE '%keyword%' 而java我记得不是很清楚了，大概是 if(myString.indexOf(keyword) != -1){ //do things... } 这个只是简单匹配，如果有复杂要求就要写多得多的代码了。例如判断keyword是否是一个数字开头，紧跟1个小写字母，跟随若干数字，最后以"pattern"结尾等等，就不是一行代码能写出来的了。对于上例，RegEx+Ruby的写法就是 if keyword =~ /^\d[a-z]\d+pattern$/ #do things end 上式中，//是RegEx的边界，类似""是字符串的边界一样。接下来^代表匹配的开始；\d代表数字，就是0 - 9；[a-z]就是一个从a到z的小写字母了；+是后缀，表示1个或多个，因此\d+就是1个或多个数字的意思了；最后作为关键字的pattern直接写上即可；$代表匹配的结束。 更灵活的应用就是&#124;符号和()括号了。例如判断文本是否包含x或X，RegEx就可以写 /x&#124;X/ 如果要判断文本是否包含多个连续的x或者X，例如xXX、XxX，RegEx就可以写 /(x&#124;X)+/ 如果要判断文本是否包含XXX、XXXX、XXXXX，RegEx可以写 /X{3,5} / 目前的了解就是这么多了，不过以上这些组合起来应该已经可以应付很多种情况了。继续学习。 © raynix for #raynix#, 2007. &#124; Permalink &#124; 唉, 一个评论都没 &#124; Add to del.icio.us Post tags: regex, ruby on rails [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://raynix.bjqnc.com/wp-content/uploads/2007/04/img_regex_big.gif" alt="img_regex_big.gif" /></p>
<p>RegEx中文叫做正则表达式，虽然不是很新的东西了，我很纳闷我居然是才开始了解它。在数据库中查询keyword一般是写成</p>
<p>select * from tablename where columnname LIKE '%keyword%'</p>
<p>而java我记得不是很清楚了，大概是</p>
<p>if(myString.indexOf(keyword) !=  -1){<br />
//do things...<br />
}</p>
<p>这个只是简单匹配，如果有复杂要求就要写多得多的代码了。例如判断keyword是否是一个数字开头，紧跟1个小写字母，跟随若干数字，最后以"pattern"结尾等等，就不是一行代码能写出来的了。对于上例，RegEx+Ruby的写法就是</p>
<p>if keyword =~ /^\d[a-z]\d+pattern$/<br />
#do things<br />
end</p>
<p>上式中，//是RegEx的边界，类似""是字符串的边界一样。接下来^代表匹配的开始；\d代表数字，就是0 - 9；[a-z]就是一个从a到z的小写字母了；+是后缀，表示1个或多个，因此\d+就是1个或多个数字的意思了；最后作为关键字的pattern直接写上即可；$代表匹配的结束。</p>
<p>更灵活的应用就是|符号和()括号了。例如判断文本是否包含x或X，RegEx就可以写</p>
<p>/x|X/</p>
<p>如果要判断文本是否包含多个连续的x或者X，例如xXX、XxX，RegEx就可以写</p>
<p>/(x|X)+/</p>
<p>如果要判断文本是否包含XXX、XXXX、XXXXX，RegEx可以写</p>
<p>/X{3,5} /</p>
<p>目前的了解就是这么多了，不过以上这些组合起来应该已经可以应付很多种情况了。继续学习。</p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2007. |
<a href="http://raynix.info/archives/64">Permalink</a> |
<a href="http://raynix.info/archives/64#comments">唉, 一个评论都没</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/64&title=牛刀小试RegEx">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/regex" rel="tag">regex</a>, <a href="http://raynix.info/archives/tag/ruby-on-rails" rel="tag">ruby on rails</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/64/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>梦想成真：用idea开发ruby on rails</title>
		<link>http://raynix.info/archives/38</link>
		<comments>http://raynix.info/archives/38#comments</comments>
		<pubDate>Mon, 12 Mar 2007 08:21:04 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Opensource]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://raynix.bjqnc.com/archives/38</guid>
		<description><![CDATA[用java做东东的朋友应该都知道JetBrains（下简称JB）和他们的杰作IntelliJ IDEA（下简称IDEA）。JB的口号是develop with pleasure，快乐的开发。而rails的口号是web development that doesn't hurt，这个不大好直接翻译了，不痛苦的web开发？HOHO，现在是快乐＋无痛苦了，因为IDEA的新插件支持rails开发了。我睡觉都要笑醒了。 此插件的链接在此 。主要功能如下： keyword completion，关键字辅助完成 syntax highlighting，句法高亮显示 on-the-fly code validation，即时代码检验 error highlighting，错误高亮显示 Rails templates and generator integration，模版、生成器集成 最后，IDEA开放了开源软件许可，就是说，如果你手头有个开源项目，有项目网站、活跃的项目论坛，那么你可以申请免费的IDEA许可！省了400多美刀哦～ 我也要建个项目:-) © raynix for #raynix#, 2007. &#124; Permalink &#124; 唉, 一个评论都没 &#124; Add to del.icio.us Post tags: ruby on rails Feed enhanced by Better Feed from Ozh]]></description>
			<content:encoded><![CDATA[<p><img src="http://raynix.bjqnc.com/wp-content/uploads/2007/03/rails.png" alt="rails.png" align="left" hspace="4" /><img src="http://raynix.bjqnc.com/wp-content/uploads/2007/03/jb_logo.gif" alt="jb_logo.gif" align="left" hspace="4" /> 用java做东东的朋友应该都知道JetBrains（下简称JB）和他们的杰作IntelliJ IDEA（下简称IDEA）。JB的口号是develop with pleasure，快乐的开发。而rails的口号是web development that doesn't hurt，这个不大好直接翻译了，不痛苦的web开发？HOHO，现在是快乐＋无痛苦了，因为IDEA的新插件支持rails开发了。我睡觉都要笑醒了。</p>
<p>此插件的链接<a href="http://www.jetbrains.com/idea/features/ruby_development.html" target="_blank">在此</a> 。主要功能如下：</p>
<ul>
<li>keyword completion，关键字辅助完成</li>
<li>syntax highlighting，句法高亮显示</li>
<li>on-the-fly code validation，即时代码检验</li>
<li>error highlighting，错误高亮显示</li>
<li>Rails templates and generator integration，模版、生成器集成</li>
</ul>
<p>最后，IDEA开放了开源软件许可，就是说，如果你手头有个开源项目，有项目网站、活跃的项目论坛，那么你可以申请免费的IDEA许可！省了400多美刀哦～ 我也要建个项目:-)</p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2007. |
<a href="http://raynix.info/archives/38">Permalink</a> |
<a href="http://raynix.info/archives/38#comments">唉, 一个评论都没</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/38&title=梦想成真：用idea开发ruby on rails">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/ruby-on-rails" rel="tag">ruby on rails</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/38/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby笔记之一</title>
		<link>http://raynix.info/archives/19</link>
		<comments>http://raynix.info/archives/19#comments</comments>
		<pubDate>Tue, 04 Jul 2006 06:46:59 +0000</pubDate>
		<dc:creator>raynix</dc:creator>
				<category><![CDATA[Opensource]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://raynix.bjqnc.com/archives/19</guid>
		<description><![CDATA[1，随意，更象人类的语言 java: if(a == b) { System.out. ....//already forgotton? } ruby: puts "it's right!" if a == b 2，纯粹的OOP java: MyClass my = new MyClass("param"); //';' required int i = Math.abs(-5); ruby: my = MyClass.new("param") #no ';' required i = -5.abs #see, even -5 is an object 3，灵活 java: public String hello(String sir){ return "hello, [...]]]></description>
			<content:encoded><![CDATA[<p>1，随意，更象人类的语言<br />
java:<br />
if(a == b) {<br />
System.out. ....//already forgotton? <img src='http://raynix.info/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /><br />
}</p>
<p>ruby:<br />
puts "it's right!" if a == b</p>
<p>2，纯粹的OOP<br />
java:<br />
MyClass my = new MyClass("param"); //';' required<br />
int i = Math.abs(-5);</p>
<p>ruby:<br />
my = MyClass.new("param") #no ';' required<br />
i = -5.abs #see, even -5 is an object</p>
<p>3，灵活<br />
java:<br />
public String hello(String sir){<br />
return "hello, " + sir + "!";<br />
}</p>
<p>ruby:<br />
def hello(sir)<br />
"hello, #{sir}!" #the last line's value will be the returned value.<br />
end</p>
<p>4，人性、人性！<br />
任务：打印n个*出来<br />
java:<br />
for(int i=0;i<n;i++)></n;i++)></p>
<p>ruby:<br />
n.times { print "*"}</p>
<p>5，容错<br />
java:<br />
int[] i = {1,2,3};<br />
i[5] = 99; //boom!!! ArrayIndexOutxxxException!!!</p>
<p>ruby:<br />
i = [1,2,3]<br />
i[5] = 99 # i is now [1,2,3,nil,nil,99]</p>
<p>待续……</p>
<hr />
<p><small>© raynix for <a href="http://raynix.info">#raynix#</a>, 2006. |
<a href="http://raynix.info/archives/19">Permalink</a> |
<a href="http://raynix.info/archives/19#comments">唉, 一个评论都没</a> |
Add to
<a href="http://del.icio.us/post?url=http://raynix.info/archives/19&title=ruby笔记之一">del.icio.us</a>
<br/>
Post tags: <a href="http://raynix.info/archives/tag/ruby-on-rails" rel="tag">ruby on rails</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://raynix.info/archives/19/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
