<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;C0ACR3k-fyp7ImA9WhRRFEk.&quot;"><id>tag:blogger.com,1999:blog-1074492543142349295</id><updated>2011-11-28T09:56:06.757+09:00</updated><category term="framework" /><category term="ubuntu" /><category term="aggregator" /><category term="python" /><category term="helper" /><category term="tips" /><category term="wsgi" /><category term="rss" /><category term="rails" /><title>脳みそダンプ</title><subtitle type="html">あらゆる開発言語で開発をしている人のブログ</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://vik-braindump.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://vik-braindump.blogspot.com/" /><author><name>Vik</name><uri>http://www.blogger.com/profile/01527757915984965095</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/-Y63oNKagFdA/TnNQ7Yt8IjI/AAAAAAAAAIQ/RMdhSyC4P7o/s1600/fb_reasonably_small.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/vik-braindump" /><feedburner:info uri="vik-braindump" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;C08MR3ozeip7ImA9WxNTEk8.&quot;"><id>tag:blogger.com,1999:blog-1074492543142349295.post-8062499803467136400</id><published>2009-08-14T12:51:00.001+09:00</published><updated>2009-08-14T12:51:26.482+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-14T12:51:26.482+09:00</app:edited><title>急に都内に泊まってみた</title><content type="html">&lt;a href="http://www.flickr.com/photos/30558366@N08/3819702074/" title="photo sharing"&gt;&lt;img src="http://farm4.static.flickr.com/3422/3819702074_8d176966e4_m.jpg" alt="" style="border: solid 2px #000000;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: 0.9em; margin-top: 0px;"&gt;&lt;a href="http://www.flickr.com/photos/30558366@N08/3819702074/"&gt;Udon @ Tsurutontan Roppongi&lt;/a&gt; &lt;br /&gt;Originally uploaded by &lt;a href="http://www.flickr.com/people/30558366@N08/"&gt;vik_122&lt;/a&gt;&lt;/span&gt;&lt;br clear="all" /&gt;&lt;p&gt;世の中はお盆休みのようで。&lt;br /&gt;仕事中に急に奥様から「ホテルオークラに泊まろう」と連絡があったので」六本木で合流した。&lt;br /&gt;&lt;br /&gt;いつも混んでいて入るのを躊躇していたおうどんのお店、「つるとんたん六本木店」に30分待ちでいってみた。&lt;br /&gt;&lt;br /&gt;海老真蒸と胡麻団子のおうどんに温泉卵をつけてみた。なかなか美味しかったよ。&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1074492543142349295-8062499803467136400?l=vik-braindump.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sxBQAeEkemt3Y6FwxQve90oOhPI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sxBQAeEkemt3Y6FwxQve90oOhPI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sxBQAeEkemt3Y6FwxQve90oOhPI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sxBQAeEkemt3Y6FwxQve90oOhPI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/vik-braindump/~4/BkmB4XI4ncQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vik-braindump.blogspot.com/feeds/8062499803467136400/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1074492543142349295&amp;postID=8062499803467136400" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/8062499803467136400?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/8062499803467136400?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/vik-braindump/~3/BkmB4XI4ncQ/blog-post.html" title="急に都内に泊まってみた" /><author><name>Vik</name><uri>http://www.blogger.com/profile/01527757915984965095</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/-Y63oNKagFdA/TnNQ7Yt8IjI/AAAAAAAAAIQ/RMdhSyC4P7o/s1600/fb_reasonably_small.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://farm4.static.flickr.com/3422/3819702074_8d176966e4_t.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://vik-braindump.blogspot.com/2009/08/blog-post.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4BQ3w7eCp7ImA9WxdbFE8.&quot;"><id>tag:blogger.com,1999:blog-1074492543142349295.post-4818187116878476686</id><published>2008-08-08T10:05:00.002+09:00</published><updated>2008-08-11T11:49:12.200+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-11T11:49:12.200+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="wsgi" /><category scheme="http://www.blogger.com/atom/ns#" term="framework" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>wsgiで俺フレームワークでも作ろうか</title><content type="html">&lt;a href="http://www.japanvik.net/"&gt;japanvik.net&lt;/a&gt;のリニューアルをしたくなったので、この際wsgiの勉強も兼ねてmvcな俺フレームワークでもつかって見ようかと思う。&lt;br /&gt;&lt;br /&gt;サイトのコンセプトは「俺ポータル」 - 自分のブログのアグレゲート済みRSSやTwitterやコードなど、自分のまとめサイトにしたいと思っている。&lt;br /&gt;しばらくwsgi関連のサイトを巡回しながらコードをちょこちょこ書いている。現段階では次のような仕組みで作っている：&lt;br /&gt;&lt;br /&gt;テンプレートエンジン: mako + ドキュメント用にmarkdown2&lt;br /&gt;URLディスパッチャー: selector + pasteのstatic&lt;br /&gt;その他自分で書いたものちょこちょこ&lt;br /&gt;&lt;br /&gt;本当はelixirでdb接続を行いたいのだけど、dbへのコネクションの維持のあたりがよく解っていないので、今のところdb接続はは無し。Pylonsのコードでも釣ってみようかな。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DBの接続まで出来たら今時のmvcフレームワークとして成立するので、機会があれば公開しようと思う。比較的小規模なサイトならサクサクと出来てしまいそう。ただ、このままいくと、ほぼPylonsになってしまう気配がw&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1074492543142349295-4818187116878476686?l=vik-braindump.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tIkO0Bmxffv4PG80hXbQPFXqTGs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tIkO0Bmxffv4PG80hXbQPFXqTGs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tIkO0Bmxffv4PG80hXbQPFXqTGs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tIkO0Bmxffv4PG80hXbQPFXqTGs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/vik-braindump/~4/Ki-uEtzd_wM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vik-braindump.blogspot.com/feeds/4818187116878476686/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1074492543142349295&amp;postID=4818187116878476686" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/4818187116878476686?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/4818187116878476686?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/vik-braindump/~3/Ki-uEtzd_wM/wsgi.html" title="wsgiで俺フレームワークでも作ろうか" /><author><name>Vik</name><uri>http://www.blogger.com/profile/01527757915984965095</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/-Y63oNKagFdA/TnNQ7Yt8IjI/AAAAAAAAAIQ/RMdhSyC4P7o/s1600/fb_reasonably_small.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://vik-braindump.blogspot.com/2008/08/wsgi.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIGQnozfyp7ImA9WB5bEU4.&quot;"><id>tag:blogger.com,1999:blog-1074492543142349295.post-766019507782169223</id><published>2007-08-26T15:58:00.000+09:00</published><updated>2007-08-26T21:48:43.487+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-26T21:48:43.487+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="wsgi" /><category scheme="http://www.blogger.com/atom/ns#" term="aggregator" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="rss" /><title>A Python port of the Agile RSS Aggregator in Ruby</title><content type="html">I came across an  &lt;a href="http://www.igvita.com/blog/2007/03/22/agile-rss-aggregator-in-ruby"&gt;Agile RSS Aggregator in Ruby&lt;/a&gt; which had very elegant code, so I decided to port it to Python. It uses wsgi, the &lt;a href="http://www.feedparser.org/"&gt;Universal Feed Parser&lt;/a&gt;, and the &lt;a href="http://www.makotemplates.org/"&gt;Mako Template&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Here is the code:&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;#!/usr/bin/python&lt;br /&gt;from wsgiref.simple_server import make_server&lt;br /&gt;from mako.template import Template&lt;br /&gt;import feedparser&lt;br /&gt;&lt;br /&gt;class Feed:&lt;br /&gt; """ A Python port of the "Agile RSS Aggregator in Ruby"&lt;br /&gt;     See README for details&lt;br /&gt; """&lt;br /&gt; def __init__(self, environ, start_response):&lt;br /&gt;     self.environ = environ&lt;br /&gt;     self.start = start_response&lt;br /&gt; &lt;br /&gt; def __iter__(self):&lt;br /&gt;     status = "200 OK"&lt;br /&gt;     response_headers = [('Content-type','text/html')]&lt;br /&gt;     self.start(status, response_headers)&lt;br /&gt;     stories = []&lt;br /&gt;     for f in open('feeds.txt', 'r'):&lt;br /&gt;         feed = feedparser.parse(f.strip())&lt;br /&gt;         stories.extend(feed.entries)&lt;br /&gt;     page = Template(filename='news.mako', output_encoding='utf8')&lt;br /&gt;     yield page.render(stories=stories)&lt;br /&gt; &lt;br /&gt;httpd= make_server("", 8000, Feed)&lt;br /&gt;httpd.serve_forever()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you compare this to the Ruby version, you can see the striking resemblance of the code. Ruby and Python are very similar when it comes to doing simple things like this.&lt;br /&gt;&lt;br /&gt;For comparison's sake, here is the relevant portion of the mako template:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;   % for item in stories:&lt;br /&gt;   &amp;lt;div class="section details"&amp;gt;&lt;br /&gt;     &amp;lt;h3&amp;gt;&amp;lt;a href="${item.link}"&amp;gt;${item.title}&amp;lt;/a&amp;gt;&amp;lt;/h3&amp;gt;&lt;br /&gt;     &amp;lt;p style="color:#444;font-size:90%;"&amp;gt;${item.summary}&amp;lt;/p&amp;gt;&lt;br /&gt;   &amp;lt;/div&amp;gt;&lt;br /&gt; % endfor&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Again, very similar to the Erubis template the original version used. Technically, I could have used something like:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;% item.link %&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;instead of :&lt;br /&gt;&lt;br /&gt;${item.link}&lt;br /&gt;&lt;br /&gt;which will make the code more similar, but I prefer the latter convention because it makes the template easier to read.&lt;br /&gt;&lt;br /&gt;One caveat is with the wsgiref.simpleserver. I couldn't find a quick way to define the static directory ("files" in the original) to serve the css style sheet. The workaround was to put the style directly in the mako template, which admittedly is a bit annoying.&lt;br /&gt;&lt;br /&gt;However, in a real world situation, chances are that we will be using an application framework like &lt;a href="http://pylonshq.com/"&gt;Pylons&lt;/a&gt; or &lt;a href="http://www.turbogears.org/"&gt;TurboGears&lt;/a&gt; which will solve the problem, so I'm not going to dig too deeply into it. If anyone knows a simple way of exposing a filesystem directory in wsgi, please let me know!&lt;br /&gt;&lt;br /&gt;Finally, here is the &lt;a href="http://www.japanvik.net/static/files/python-aggregator.tar.gz"&gt;download link&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1074492543142349295-766019507782169223?l=vik-braindump.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4_OfsN7sDcUWUQufyDxbj1IyS28/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4_OfsN7sDcUWUQufyDxbj1IyS28/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4_OfsN7sDcUWUQufyDxbj1IyS28/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4_OfsN7sDcUWUQufyDxbj1IyS28/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/vik-braindump/~4/FhP5W07MvMQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vik-braindump.blogspot.com/feeds/766019507782169223/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1074492543142349295&amp;postID=766019507782169223" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/766019507782169223?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/766019507782169223?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/vik-braindump/~3/FhP5W07MvMQ/python-port-of-agile-rss-aggregator-in.html" title="A Python port of the Agile RSS Aggregator in Ruby" /><author><name>Vik</name><uri>http://www.blogger.com/profile/01527757915984965095</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/-Y63oNKagFdA/TnNQ7Yt8IjI/AAAAAAAAAIQ/RMdhSyC4P7o/s1600/fb_reasonably_small.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://vik-braindump.blogspot.com/2007/08/python-port-of-agile-rss-aggregator-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcDRXk4cSp7ImA9WB5bF0k.&quot;"><id>tag:blogger.com,1999:blog-1074492543142349295.post-4788669536689519413</id><published>2007-06-06T13:45:00.000+09:00</published><updated>2007-09-02T23:24:34.739+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-02T23:24:34.739+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu" /><title>Fixing python-setuptools in Ubuntu Feisty</title><content type="html">Ubuntu recently upgraded its Python distribution from 2.4 to 2.5.&lt;br /&gt;Along the way, setup tools (read easy_install) seems to break itself.&lt;br /&gt;&lt;br /&gt;If your python related installs are failing and getting errors like:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;E: Sub-process /usr/bin/dpkg returned an error code (1)&lt;br /&gt;A package failed to install.  Trying to recover:&lt;br /&gt;Setting up python-setuptools (0.6c3-1ubuntu4) ...&lt;br /&gt;pycentral: pycentral pkginstall: already exists: /usr/lib/python2.4/site-packages/setuptools.pth&lt;br /&gt;pycentral pkginstall: already exists: /usr/lib/python2.4/site-packages/setuptools.pth&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then python-setuptools need to be reinstalled.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;sudo apt-get remove python-setuptools&lt;br /&gt;sudo apt-get install python-setuptools&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This fixes the dependency issue and you should be able to&lt;br /&gt;&lt;code&gt;&lt;br /&gt;easy_install Pylons TurboGears&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;without getting errors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1074492543142349295-4788669536689519413?l=vik-braindump.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/syNIaET5Qi3uPUDyoQyEi1UsyxI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/syNIaET5Qi3uPUDyoQyEi1UsyxI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/syNIaET5Qi3uPUDyoQyEi1UsyxI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/syNIaET5Qi3uPUDyoQyEi1UsyxI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/vik-braindump/~4/r7vFaL7mXL0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vik-braindump.blogspot.com/feeds/4788669536689519413/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1074492543142349295&amp;postID=4788669536689519413" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/4788669536689519413?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/4788669536689519413?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/vik-braindump/~3/r7vFaL7mXL0/fixing-python-setuptools-in-ubuntu.html" title="Fixing python-setuptools in Ubuntu Feisty" /><author><name>Vik</name><uri>http://www.blogger.com/profile/01527757915984965095</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/-Y63oNKagFdA/TnNQ7Yt8IjI/AAAAAAAAAIQ/RMdhSyC4P7o/s1600/fb_reasonably_small.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://vik-braindump.blogspot.com/2007/06/fixing-python-setuptools-in-ubuntu.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08HQXo4eyp7ImA9WBFaE0Q.&quot;"><id>tag:blogger.com,1999:blog-1074492543142349295.post-3934717239599471397</id><published>2007-05-17T17:15:00.000+09:00</published><updated>2007-05-17T17:50:30.433+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-05-17T17:50:30.433+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="tips" /><category scheme="http://www.blogger.com/atom/ns#" term="helper" /><title>[Rails] Accessing :object_name :method passed from the view in your custom helpers</title><content type="html">While making a wrapper helper to extend the functionality of the stock date_select, I needed to access the actual date object attributes within the helper method.&lt;br /&gt;&lt;br /&gt;The api of the date_select helper is like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;date_select(object_name, method, options = {})&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Where object_name is is the object in the template, and method is the method of that object which returns a date for the select boxes to show.&lt;br /&gt;&lt;br /&gt;I wanted to make an enhanced version of the date_select with some javascript goodness, while maintaining the same parameters, and needed the actual date object so I can use it on the javascript output.&lt;br /&gt;Basically I needed to do this:&lt;br /&gt;date = object_name.method&lt;br /&gt;&lt;br /&gt;Here is how I did it:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def ajax_date_select(object_name, method, options = {})&lt;br /&gt;    # Get the object_name.method value&lt;br /&gt;    date = instance_variable_get("@#{object_name.to_s.dup}").send(method.to_s.dup)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The instance_variable_get method allows you to reference the variables in the rendered view.&lt;br /&gt;So for example in the controller, if you said something like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@hoge = Hoge.find(1)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;and in the view:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;%= ajax_date_select :hoge :created_at %&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;by using instance_variable_get, you can do the equivalent of&lt;br /&gt;&lt;code&gt;&lt;br /&gt;date = hoge.created_at&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;from within the custom helper code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1074492543142349295-3934717239599471397?l=vik-braindump.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CXcqmAC1ep09q8eiksNtJmdT3yY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CXcqmAC1ep09q8eiksNtJmdT3yY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CXcqmAC1ep09q8eiksNtJmdT3yY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CXcqmAC1ep09q8eiksNtJmdT3yY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/vik-braindump/~4/SIoHZhTY3bc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://vik-braindump.blogspot.com/feeds/3934717239599471397/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1074492543142349295&amp;postID=3934717239599471397" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/3934717239599471397?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1074492543142349295/posts/default/3934717239599471397?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/vik-braindump/~3/SIoHZhTY3bc/rails-accessing-objectname-method.html" title="[Rails] Accessing :object_name :method passed from the view in your custom helpers" /><author><name>Vik</name><uri>http://www.blogger.com/profile/01527757915984965095</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/-Y63oNKagFdA/TnNQ7Yt8IjI/AAAAAAAAAIQ/RMdhSyC4P7o/s1600/fb_reasonably_small.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://vik-braindump.blogspot.com/2007/05/rails-accessing-objectname-method.html</feedburner:origLink></entry></feed>

