<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ruby-on-Rails on Yang's Blog</title><link>https://blog.yangtheman.com/tags/ruby-on-rails/</link><description>Recent content in Ruby-on-Rails on Yang's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Yang Chung</copyright><lastBuildDate>Fri, 03 Apr 2015 17:23:38 +0000</lastBuildDate><atom:link href="https://blog.yangtheman.com/tags/ruby-on-rails/index.xml" rel="self" type="application/rss+xml"/><item><title>MongoDB Query Performance Gotchas</title><link>https://blog.yangtheman.com/2015/04/03/mongodb-query-performance-gotchas/</link><pubDate>Fri, 03 Apr 2015 17:23:38 +0000</pubDate><guid>https://blog.yangtheman.com/2015/04/03/mongodb-query-performance-gotchas/</guid><description/></item><item><title>User-friendly 500 and 404 pages on Rails 3</title><link>https://blog.yangtheman.com/2012/10/11/user-friendly-500-and-404-pages-on-rails-3/</link><pubDate>Fri, 12 Oct 2012 04:07:32 +0000</pubDate><guid>https://blog.yangtheman.com/2012/10/11/user-friendly-500-and-404-pages-on-rails-3/</guid><description/></item><item><title>Simple Ruby on Rails app using Twilio API</title><link>https://blog.yangtheman.com/2012/04/10/simple-ruby-on-rails-app-using-twilio-api/</link><pubDate>Wed, 11 Apr 2012 03:19:22 +0000</pubDate><guid>https://blog.yangtheman.com/2012/04/10/simple-ruby-on-rails-app-using-twilio-api/</guid><description/></item><item><title>Facebook Connect with Rails (using Omniauth and Devise) [Update]</title><link>https://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/</link><pubDate>Thu, 09 Feb 2012 09:47:05 +0000</pubDate><guid>https://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/</guid><description/></item><item><title>Fresh installation of Ruby, Rails, Git, RubyGems, and Postgresql 8.x</title><link>https://blog.yangtheman.com/2011/11/18/resources-for-fresh-installation-of-git-rubygems-postgresql-8-x-and-ruby-on-rails/</link><pubDate>Fri, 18 Nov 2011 09:53:34 +0000</pubDate><guid>https://blog.yangtheman.com/2011/11/18/resources-for-fresh-installation-of-git-rubygems-postgresql-8-x-and-ruby-on-rails/</guid><description/></item><item><title>Full text search on Heroku</title><link>https://blog.yangtheman.com/2010/02/28/full-text-search-on-heroku/</link><pubDate>Mon, 01 Mar 2010 04:44:37 +0000</pubDate><guid>https://blog.yangtheman.com/2010/02/28/full-text-search-on-heroku/</guid><description/></item><item><title>How to convert from MySQL to Postgres</title><link>https://blog.yangtheman.com/2010/01/30/how-to-convert-from-mysql-to-postgres/</link><pubDate>Sat, 30 Jan 2010 07:55:21 +0000</pubDate><guid>https://blog.yangtheman.com/2010/01/30/how-to-convert-from-mysql-to-postgres/</guid><description>&lt;p&gt;I have been using MySQL for probably as long as I could remember. For &lt;a href="http://www.bloglation.com" target="_blank" rel="noreferrer"&gt;Bloglation&lt;/a&gt;, search capability is an important feature since it&amp;rsquo;s hard to browse each post one by one. I will probably implement tagging functionality, but even so, it&amp;rsquo;s important to be able to search the contents with a keyword(s). While Ultrasphinx works well, Heroku only supports WebSolr&amp;hellip; I was using acts_as_ferret using /tmp for index files, but the problem using the /tmp directory is that ferret index files most likely to disappear at some point.&lt;/p&gt;
&lt;p&gt;Then, I found out that Postgres supports full-text search and since Heroku uses Postgres, I could use other plug-ins like &lt;a href="http://code.google.com/p/acts-as-tsearch/" target="_blank" rel="noreferrer"&gt;acts_as_tsearch&lt;/a&gt; or &lt;a href="http://tenderlovemaking.com/2009/10/17/full-text-search-on-heroku/comment-page-1/" target="_blank" rel="noreferrer"&gt;texticle&lt;/a&gt; for free. Free is important to me, since it&amp;rsquo;s not making any money.&lt;/p&gt;
&lt;p&gt;Searching online, there are various ways to do it like &lt;a href="http://pivotallabs.com/users/jpignata/blog/articles/1077-converting-rails-application-data-from-mysql-to-postgresql" target="_blank" rel="noreferrer"&gt;Pivotal Labs&amp;rsquo; script&lt;/a&gt; or &lt;a href="http://adam.blog.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/" target="_blank" rel="noreferrer"&gt;Heroku&amp;rsquo;s Taps gem&lt;/a&gt;, but I wanted to do it in an old way like &lt;a href="http://blog.aedifice.org/2009/09/08/converting-rails-applications-from-mysql-to-postgresql" target="_blank" rel="noreferrer"&gt;AEdifice&lt;/a&gt; to check everything is going alright at each step. &lt;strong&gt;1. First thing to do is to backup MySQL&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For me, it was important to backup preserving encoding, since it had many different languages. First I pulled db from Heroku thinking that I&lt;/p&gt;</description></item><item><title>To mock or stub 'open' method</title><link>https://blog.yangtheman.com/2009/12/16/to-mock-or-stub-open-method/</link><pubDate>Wed, 16 Dec 2009 08:17:01 +0000</pubDate><guid>https://blog.yangtheman.com/2009/12/16/to-mock-or-stub-open-method/</guid><description/></item><item><title>Bloglation - Translate, Save, and Share!</title><link>https://blog.yangtheman.com/2009/11/24/bloglation-translate-save-and-share/</link><pubDate>Tue, 24 Nov 2009 22:44:29 +0000</pubDate><guid>https://blog.yangtheman.com/2009/11/24/bloglation-translate-save-and-share/</guid><description/></item><item><title>Installing acts_as_ferret with pagination and deploying on Heroku</title><link>https://blog.yangtheman.com/2009/11/05/installing-acts_as_ferret-with-pagination-and-deploying-on-heroku/</link><pubDate>Thu, 05 Nov 2009 23:56:02 +0000</pubDate><guid>https://blog.yangtheman.com/2009/11/05/installing-acts_as_ferret-with-pagination-and-deploying-on-heroku/</guid><description>&lt;p&gt;OMG!&lt;/p&gt;
&lt;p&gt;This shouldn&amp;rsquo;t have been this difficult, but it has because while there are many cool tutorials are out there, they are mostly outdated, and for some reason, the &lt;a href="http://docs.heroku.com/full-text-indexing" target="_blank" rel="noreferrer"&gt;instruction on Heroku&lt;/a&gt; was not accessible.&lt;/p&gt;
&lt;p&gt;While I picked acts_as_ferret because Heroku supports it, many seemed to prefer &lt;a href="http://freelancing-god.github.com/ts/en/" target="_blank" rel="noreferrer"&gt;Thinking Sphinx&lt;/a&gt;. So, if you are not constrained (like me with Heroku), you should try that out too.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Install acts_as_ferret&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Full instruction is outlined on &lt;a href="http://github.com/jkraemer/acts_as_ferret" target="_blank" rel="noreferrer"&gt;github&lt;/a&gt;, so you should check it out. You can also find the installation instruction and complete list of methods &lt;a href="http://projects.jkraemer.net/rdoc/acts_as_ferret/" target="_blank" rel="noreferrer"&gt;here&lt;/a&gt;, too.&lt;/p&gt;
&lt;p&gt;While the instruction asks you to put version name, since Heroku only has version 0.4.3 installed, specifying a version will break it.&lt;/p&gt;</description></item><item><title>Counting rows and modifying MySQL to work with Postgres or Heroku</title><link>https://blog.yangtheman.com/2009/10/22/counting-rows-and-modifying-mysql-to-work-with-postgres-or-heroku/</link><pubDate>Thu, 22 Oct 2009 07:48:03 +0000</pubDate><guid>https://blog.yangtheman.com/2009/10/22/counting-rows-and-modifying-mysql-to-work-with-postgres-or-heroku/</guid><description>&lt;p&gt;Now I am moving on to Open Translation Project. I&amp;rsquo;ve done some translation work before, including one of Paul Graham&amp;rsquo;s essay - &lt;a href="http://www.paulgraham.com/notnot.html" target="_blank" rel="noreferrer"&gt;Why to not not start a startup&lt;/a&gt;. BTW, he finally made a link from the essay to my translation. I used Google Translate as base, but I couldn&amp;rsquo;t believe how bad the translation was. Yahoo&amp;rsquo;s Babel Fish was a little better, but not as much. That&amp;rsquo;s where I got the idea of creating this possibly massive project.&lt;/p&gt;
&lt;p&gt;Anyhow, I wanted to find a way of selecting an article or blog that was translated the most. I had one model that stored basic information of original article/blog. Then its children are translations. So, I need to count rows of children with the same parent. In MySQL, I had the following statement in Rails.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;@top_origs = OrigPost.find(:all,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :select =&amp;gt; &amp;#39;orig_posts.*, count(posts.id) as post_count&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :joins =&amp;gt; &amp;#39;left outer join posts on posts.orig_post_id = orig_posts.id&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :group =&amp;gt; &amp;#39;orig_posts.id&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :order =&amp;gt; &amp;#39;post_count DESC&amp;#39;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;                              :limit =&amp;gt; 5)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item><item><title>Featured on Clickpass blog</title><link>https://blog.yangtheman.com/2009/09/28/featured-on-clickpass-blog/</link><pubDate>Tue, 29 Sep 2009 06:30:50 +0000</pubDate><guid>https://blog.yangtheman.com/2009/09/28/featured-on-clickpass-blog/</guid><description/></item><item><title>How to integrate Clickpass (and OpenID) with a Rails app</title><link>https://blog.yangtheman.com/2009/09/17/how-to-integrate-clickpass-or-openid-with-a-rails-app/</link><pubDate>Thu, 17 Sep 2009 09:21:20 +0000</pubDate><guid>https://blog.yangtheman.com/2009/09/17/how-to-integrate-clickpass-or-openid-with-a-rails-app/</guid><description>&lt;p&gt;I saw &lt;a href="http://www.clickpass.com/" target="_blank" rel="noreferrer"&gt;Clickpass&lt;/a&gt; in action at the &lt;a href="http://news.ycombinator.com" target="_blank" rel="noreferrer"&gt;Hacker News&lt;/a&gt;, and I thought it was another great way to reduce another login account. I wanted to implement it for my &lt;strong&gt;Open Translation&lt;/strong&gt; project.&lt;/p&gt;
&lt;p&gt;However, when I tried to find tutorials for using Clickpass with a Rails app, I couldn&amp;rsquo;t find any! How could it be! The pesudo code example Clickpass provided was for Java, I think, and thus it wasn&amp;rsquo;t any help to me. I was completely lost.&lt;/p&gt;
&lt;p&gt;Then I realized that in the core underlying architecture of Clickpass is OpenID. Then it all made sense to me. I found a great tutorial on OpenID and Authlogic on a &lt;a href="http://railscasts.com/episodes/170-openid-with-authlogic" target="_blank" rel="noreferrer"&gt;Railscasts episode&lt;/a&gt; (I am not using Authlogic for my site, though, but for the Open Translation project, I probably will.). So the following is a mixture of the Railscasts episode, &lt;strong&gt;ruby-openid&lt;/strong&gt; gem, &lt;strong&gt;open_id_authentication&lt;/strong&gt; plugin and Clickpass setup.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Install the gem and the plugin.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo gem install ruby-openid&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item><item><title>How to integrate Facebook Feed with a Rails app</title><link>https://blog.yangtheman.com/2009/09/09/integrating-facebook-feed-with-a-rails-app/</link><pubDate>Wed, 09 Sep 2009 07:17:28 +0000</pubDate><guid>https://blog.yangtheman.com/2009/09/09/integrating-facebook-feed-with-a-rails-app/</guid><description>&lt;p&gt;On Monday, I&amp;rsquo;ve gotten Facebook Feed publishing to work with my site, and it took about two hours including TV watching time. I could&amp;rsquo;ve done it faster if I actually paid a full attention. It was all possible, thanks to Chris Schmitt, who has an excellent &lt;a href="http://www.thoughtintomotion.com/2009/06/publish-feed-stories-with-facebooker-rails.html" target="_blank" rel="noreferrer"&gt;tutorial&lt;/a&gt; on his site.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Simply you first need to create a sub-class inherited from &lt;strong&gt;Facebooker::Rails::Publisher&lt;/strong&gt; inside a controller. In my case, I wanted to publish a feed when a new playground is added and an existing playground is edited, so it made a sense to put it in &lt;strong&gt;playgrounds&lt;/strong&gt; controller. &lt;strong&gt;publish_pg&lt;/strong&gt; takes objects and sets parameters, and &lt;strong&gt;publish_pg_template&lt;/strong&gt; creates a feed message based on those parameters.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;class PlaygroundsController &amp;lt; ApplicationController
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[SNIP - other actions]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; class FacebookPublisher &amp;lt; Facebooker::Rails::Publisher
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; def publish_pg_template
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; one_line_story_template &amp;#34;{*actor*} created/updated: {*pg_name*}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; short_story_template &amp;#34;{*actor*} created/updated: {*pg_name*} in {*pg_city*}, {*pg_state*}&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Check out what {*actor*} said, and rate or add comments to help other parents!&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; def publish_pg(pg, facebook_session)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; send_as :user_action
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; from facebook_session.user
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; data :actor =&amp;gt; facebook_session.user.first_name, :pg_name =&amp;gt; pg.name, :pg_city =&amp;gt; pg.city, :pg_state =&amp;gt; pg.state, :pg_id =&amp;gt; pg.id
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;**&lt;/p&gt;</description></item><item><title>Deploying a Rails app on Heroku (paperclip, gems, yml)</title><link>https://blog.yangtheman.com/2009/09/05/deploying-a-rails-app-on-heroku-paperclip-gems-yml/</link><pubDate>Sat, 05 Sep 2009 08:57:21 +0000</pubDate><guid>https://blog.yangtheman.com/2009/09/05/deploying-a-rails-app-on-heroku-paperclip-gems-yml/</guid><description>&lt;p&gt;I just moved my &lt;a href="http://www.playgroundrus.com" target="_blank" rel="noreferrer"&gt;PlaygroundsRUs&lt;/a&gt; site from &lt;a href="http://aws.amazon.com/ec2/" target="_blank" rel="noreferrer"&gt;AWS&lt;/a&gt; to &lt;a href="http://heroku.com/" target="_blank" rel="noreferrer"&gt;Heroku&lt;/a&gt;, and I couldn&amp;rsquo;t be happier. My first full month bill from Amazon was about $75, and $74 of that (99% of the total cost) was for running an instance. &lt;a href="http://www.harlanknight.net/pub/H@rlan_Knight_Wood/" target="_blank" rel="noreferrer"&gt;Harlan&lt;/a&gt; told me about Heroku after he deployed his &lt;a href="http://fork-this-demo.heroku.com/login" target="_blank" rel="noreferrer"&gt;ForkThis&lt;/a&gt; demo on there.&lt;/p&gt;
&lt;p&gt;Most of the transition was smooth, but there were a few hiccups on the way. One of them still hasn&amp;rsquo;t been resolved (one of the plugins is having conflict with PostgresSQL, which is used by Heroku). I will enumerate what I had to go through so that it might be easier for you.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Secret YAML files&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have a public GitHub account for deploying on AWS using &lt;a href="http://ec2onrails.rubyforge.org/" target="_blank" rel="noreferrer"&gt;ec2onrails&lt;/a&gt;. Since it&amp;rsquo;s public and anyone can see it, I had to omit sensitive &lt;code&gt;.yml&lt;/code&gt; files in config directory that contained passwords and keys. It&amp;rsquo;s easily done by specifying those files in &lt;code&gt;.gitignore&lt;/code&gt; and listing them in &lt;code&gt;:nonvc_configs&lt;/code&gt; in &lt;code&gt;config/deploy.rb&lt;/code&gt; used by ec2onrails.&lt;/p&gt;
&lt;p&gt;I found out that for Heroku, the same can be achieved by creating another branch, including those files, merging with master, and pushing it to Heroku. So, the following lines should do the trick.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git checkout production
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[remove those yml files from .gitignore]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git merge master
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git push heroku production:master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;**&lt;/p&gt;</description></item><item><title>How to integrate Google Maps in a Rails app</title><link>https://blog.yangtheman.com/2009/08/27/how-to-integrate-google-maps-in-a-rails-app/</link><pubDate>Thu, 27 Aug 2009 20:08:28 +0000</pubDate><guid>https://blog.yangtheman.com/2009/08/27/how-to-integrate-google-maps-in-a-rails-app/</guid><description>&lt;p&gt;The major part of my experiment was going to be the integration with Google Maps. At first, I was a bit apprehensive about it, but Ruby on Rails being a community oriented language, I found a couple of quite useful plug-ins. With them, finding a location based on address or geocode or finding nearby places based on certain radius of a location were not too hard.&lt;/p&gt;
&lt;p&gt;There is actually an excellent book also, called &lt;a href="http://books.google.com/books?id=E90Dg0N-FQkC&amp;amp;dq=google&amp;#43;maps&amp;#43;rails&amp;amp;source=gbs_navlinks_s" target="_blank" rel="noreferrer"&gt;Beginning Google maps applications with Rails and Ajax&lt;/a&gt;. But the problem with the book is that it was geared towards more for java developers using rails. Thus, its major functions were javascripts and it showed how to talk to rails app. In my case, since I wanted simple features and I didn&amp;rsquo;t want to take time to learn javascript, I decided to find a simpler way.&lt;/p&gt;
&lt;p&gt;And I found that for things I wanted to do, I could do with &lt;a href="http://ym4r.rubyforge.org/ym4r_gm-doc/" target="_blank" rel="noreferrer"&gt;YM4R/GM&lt;/a&gt; and &lt;a href="http://geokit.rubyforge.org/" target="_blank" rel="noreferrer"&gt;Geokit&lt;/a&gt;. There are other excellent tutorials out there like the &lt;a href="http://www.developer.com/open/article.php/3757576" target="_blank" rel="noreferrer"&gt;one&lt;/a&gt; by Jason Gilmore on Developer.com.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s begin.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Sign-up for Google Maps API by going to &lt;a href="http://code.google.com/apis/maps/signup.html" target="_blank" rel="noreferrer"&gt;here&lt;/a&gt;. For development environment, you can use either http://localhost:3000 or http://127.0.0.1:300 as the website URL. Copy the API key.&lt;/p&gt;
&lt;p&gt;When you move to production environment, make sure you come back here to get another key for production URL.&lt;/p&gt;</description></item><item><title>Singleton Class, acts_as_rated and twitterify in Rails</title><link>https://blog.yangtheman.com/2009/08/27/singleton-class-acts_as_rated-and-twitterify-in-rails/</link><pubDate>Thu, 27 Aug 2009 17:14:06 +0000</pubDate><guid>https://blog.yangtheman.com/2009/08/27/singleton-class-acts_as_rated-and-twitterify-in-rails/</guid><description>&lt;p&gt;Today, I went to &lt;a href="http://ruby.meetup.com/117/" target="_blank" rel="noreferrer"&gt;San Jose Ruby Hackfest meetup&lt;/a&gt;, and met a bunch of cool guys. One of them was &lt;a href="http://blog.angelbob.com/posts" target="_blank" rel="noreferrer"&gt;Noah Gibbs&lt;/a&gt;, who helped me tremendously with one of the most pesky problems I had.&lt;/p&gt;
&lt;p&gt;Before you go on, you might want to read up on really good tutorials on &lt;a href="http://jonesbunch.com/articles/2008/ruby-singleton" target="_blank" rel="noreferrer"&gt;Singleton Class&lt;/a&gt; and &lt;a href="http://blog.angelbob.com/posts/20" target="_blank" rel="noreferrer"&gt;Self variable&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>How to integrate Facebook Connect with a Rails app</title><link>https://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/</link><pubDate>Mon, 24 Aug 2009 05:36:59 +0000</pubDate><guid>https://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/</guid><description>&lt;p&gt;&lt;em&gt;Update: I have written up another post for using Devise and Omniauth, and you can find it &lt;a href="http://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/" target="_blank" rel="noreferrer"&gt;here&lt;/a&gt;. Facebooker is no longer maintained.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Top of my to-do list was to integrate Facebook Connect with my Rails app, since 1) there are A LOT of people using Facebook and 2) having to register to post or edit could be an obstacle in getting more users to use my site.&lt;/p&gt;
&lt;p&gt;I looked on the web for a while, and found a great example by Stuart Eccles at &lt;a href="http://www.madebymany.co.uk/tutorial-for-restful_authentication-on-rails-with-facebook-connect-in-15-minutes-00523" target="_blank" rel="noreferrer"&gt;Made by Many&lt;/a&gt;. It&amp;rsquo;s an awesome tutorial, but it&amp;rsquo;s for restful_authentication. I don&amp;rsquo;t use it, so I had to modify it a little bit. Also, I added a step to ask a user to pick a username. So the following instruction is basically modification of Stuart&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;Without further ado, let&amp;rsquo;s begin.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Setup Facebook Application page&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.1.&lt;/strong&gt; Go to this &lt;a href="http://www.facebook.com/developers/#/developers/createapp.php" target="_blank" rel="noreferrer"&gt;page&lt;/a&gt;, and enter a name for your application. I named mine &amp;ldquo;Playgrounds_R_Us&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.2.&lt;/strong&gt; Make a note of &lt;strong&gt;Application ID&lt;/strong&gt;, &lt;strong&gt;API Key&lt;/strong&gt;, and &lt;strong&gt;Secret&lt;/strong&gt;. You need it for &lt;strong&gt;facebooker.yml&lt;/strong&gt; later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.3.&lt;/strong&gt; Next is &lt;strong&gt;Authentication&lt;/strong&gt; section. Here what&amp;rsquo;s important is &lt;strong&gt;Post-Authroize&lt;/strong&gt; and &lt;strong&gt;Post-Remove Callback URL&lt;/strong&gt;. They refer to a web page a user will be taken to after logging into and logging out of Facebook account. While testing, I left it at &amp;ldquo;http://127.0.0.1:3000&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.4.&lt;/strong&gt; I also used the same URL (http://127.0.0.1:3000) for &lt;strong&gt;Canvas Callback URL&lt;/strong&gt; in &lt;strong&gt;Canvas&lt;/strong&gt; section and &lt;strong&gt;Connect URL&lt;/strong&gt; in &lt;strong&gt;Connect&lt;/strong&gt; section.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.5.&lt;/strong&gt; Then you are pretty much set with configuration on Facebook side.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Get &lt;a href="http://github.com/mmangino/facebooker/tree/master" target="_blank" rel="noreferrer"&gt;facebooker&lt;/a&gt; plugin and install it. From your rails app root directory,&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ruby script/plugin install git://github.com/mmangino/facebooker.git&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item><item><title>Alpha version of Playgrounds R Us is launched</title><link>https://blog.yangtheman.com/2009/08/04/alpha-version-of-playgrounds-r-us-is-launched/</link><pubDate>Tue, 04 Aug 2009 21:10:35 +0000</pubDate><guid>https://blog.yangtheman.com/2009/08/04/alpha-version-of-playgrounds-r-us-is-launched/</guid><description/></item></channel></rss>