Heroku staging for your rails app

Heroku is the best platform to host our rails applications for free. Many people are using heroku to live their applications. Whenever you hosted your rails app on heroku, by default it runs in production mode. Now if you want to run your app on staging you specify some configuration. Here they are:

1) First create a file staging.rb in ‘config/environments/‘ directory and copy the contents which are there in production.rb file.

     Note: Please see contents and then copy.

2) Do necessary configurations what you need for your app to run application in staging mode. In my case I did configuration for facebook.

3) Next run this ‘heroku config:add RACK_ENV=staging‘ . It will restart your app in staging mode. Now access URL. That’s it.

Any suggestions or feedback would be welcome.

Building a facebook app

Now-a-days people are crazy about building Facebook apps. Through this site their app would get more mass attention than normal app. Now I will show how to build facebook app using rails.

1) First your app should needs to register with facebook. Through this link you can register .

2) After your registration you will get app-id, api-key, and secret-key which will be used to identify your app.

3) While registering your app you should give a site URL in web-site tab which tells you where your app is running. In my app, I have given http://127.0.0.1:8080/. As I am hosting my rails app on my local machine which is running on port 8080.

4) In facebook integration tab you should specify canvas page as you like. In my app I have given as http://apps.facebook.com/new_app/. After that you should specify canvas URL and tab URL as same as site URL. Then click on save changes.

Now you are ready with facebook settings is in your hand. Now you need to create rails app.

In rails app I have used facebooker2 gem. Follow this link and set facebooker2 gem for your project. After you configured, run your rails server on port 8080 and access canvas page URL after your signed in facebook. Then see the magic, your app will be rendered inside IFrame of facebook.

Bcrypt-ruby installation issues in linux

Hi

Today, I did production server setup on Amazon EC2 server. Even though I have experience to do how to setup but bcrypt-ruby installation will suffered me alot. I have got following errors when I am doing ‘bundle install’


Installing bcrypt-ruby (2.1.4) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby extconf.rb
 mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h

Gem files will remain installed in /home/deploy/.bundler/tmp/29722/gems/bcrypt-ruby-2.1.4 for inspection.
 Results logged to /home/deploy/.bundler/tmp/29722/gems/bcrypt-ruby-2.1.4/ext/mri/gem_make.out
 from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each'
 from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
 from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/source.rb:100:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:58:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:90:in `with_build_args'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:57:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:49:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:8:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/cli.rb:222:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:22:in `send'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:22:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor.rb:246:in `dispatch'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/base.rb:389:in `start'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/bin/bundle:13
 from /usr/bin/bundle:19:in `load'
 from /usr/bin/bundle:19

Reason: It didn’t find ruby header files to do native compilation. For that you need to install ruby-development packages. Here is the way to install in RedHat:

1) yum search ruby. This will give all packages. Pick the package name and do

2) yum install “package-name”

After installation ruby-dev packages and doing bundle install I got following error:


Installing bcrypt-ruby (2.1.4) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/bin/ruby extconf.rb
 creating Makefile

make
 sh: make: command not found

Gem files will remain installed in /home/deploy/.bundler/tmp/30223/gems/bcrypt-ruby-2.1.4 for inspection.
 Results logged to /home/deploy/.bundler/tmp/30223/gems/bcrypt-ruby-2.1.4/ext/mri/gem_make.out
 from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each'
 from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
 from /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/source.rb:100:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:58:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:90:in `with_build_args'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:57:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:49:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:8:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/cli.rb:222:in `install'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:22:in `send'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:22:in `run'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor.rb:246:in `dispatch'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/base.rb:389:in `start'
 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.13/bin/bundle:13
 from /usr/bin/bundle:19:in `load'
 from /usr/bin/bundle:19

For this you need install ‘make’. Here is the way to install in RedHat

yum install make

I hope no one won’t face this problem again. Any feedback would be welcome.