Life Of Navin

Random Musings, Random Bullshit.

kc

Using Hobo With Rails 3 and MySQL!

For my college project this semester, We (me, Damodar "Damu" Dukle and Poonam "Patlinbai" Patil) chose to use Ruby on Rails, a framework that has been used to create tonnes of stunning webapps. As a developer, Ruby on Rails (or RoR) has been of great interest since the "Convention over Configuration" philosophy RoR emphasizes upon leads to a quick, non-repetitive coding. For the backend, we decided to stick with MySQL, a SQL that all 3 of us are experienced and comfortable with.

Now for our project, we'll be designing a webapp called Press Play, a sort of Napster meets Last.FM meets SoundCloud mega-mashup... more on that some other time (probably once we finish it).

Now, one of the first things we needed to get done was user authentication. And I recalled Kaustubh (@geekblues) telling me about Hobo, a framework that builds upon RoR, and simplifies tasks such as user authentication, permissions and object lifecycles. And after using Hobo, I must say, I am very impressed! :)

The following is a simple tutorial to get up and running with Hobo on Rails 3.x.

1. Setup Ruby and Ruby on Rails. Follow this tutorial if you need to.

2. Next step is ofcourse to install the Hobo gem. Now there's a small issue here. If you use the stadard gem install hobo command, it installs Hobo 1.0.3, which is incompatible with Rails 3.x. Hence we use the command gem install hobo --pre , which installs a prebuild of Hobo 1.3.0, which is compatible with Rails 3.x.

C:\Press_Play>gem install hobo --pre
Fetching: hobo-1.3.0.pre29.gem (100%)
Successfully installed hobo-1.3.0.pre29
1 gem installed
Installing ri documentation for hobo-1.3.0.pre29...
Installing RDoc documentation for hobo-1.3.0.pre29...

3. Start MySQL . Let's use XAMPP here as well (as discussed here). Install the mysql and mysql2 gems using

C:\Press_Play>gem install mysql
Fetching: mysql-2.8.1-x86-mingw32.gem (100%)
Successfully installed mysql-2.8.1-x86-mingw32
1 gem installed
Installing ri documentation for mysql-2.8.1-x86-mingw32...
Installing RDoc documentation for mysql-2.8.1-x86-mingw32...

C:\Press_Play>gem install mysql2
Fetching: mysql2-0.2.6-x86-mingw32.gem (100%)
Successfully installed mysql2-0.2.6-x86-mingw32
1 gem installed
Installing ri documentation for mysql2-0.2.6-x86-mingw32...
Installing RDoc documentation for mysql2-0.2.6-x86-mingw32...

Navigate to the XAMPP install folder ->mysql ->bin (Generally C:\XAMPP\mysql\bin) and then copy the libmysql.dll file. Paste it in the Ruby install folder-> bin (Generally Ruby192/bin). Overwrite if you need to.

4. Run XAMPP and Start the MySQL service from the Control panel


5. Now it's time to put Hobo into action. Assuming your project name is Press Play (stop copying our project! :P ) and you too want to use MySQL, do the following

C:\Press_Play>hobo new Press-Play -d mysql
Hobo Command Line Interface 1.3.0.pre29
Generating Rails infrastructure...
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create log
create log/server.log
create log/production.log
create log/development.log
create log/test.log
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create public/images
create public/images/rails.png
create public/stylesheets
create public/stylesheets/.gitkeep
create public/javascripts
create public/javascripts/application.js
create public/javascripts/controls.js
create public/javascripts/dragdrop.js
create public/javascripts/effects.js
create public/javascripts/prototype.js
create public/javascripts/rails.js
create script
create script/rails
create test
create test/fixtures
create test/functional
create test/integration
create test/performance/browsing_test.rb
create test/test_helper.rb
create test/unit
create tmp
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create vendor/plugins
create vendor/plugins/.gitkeep
apply C:/Users/navin/AppData/Local/Temp/hobo_app_template
gemfile hobo (>= 1.3.0.pre29)

Now is where Hobo shows it's strength... the Hobo Setup Wizard offers to run. Let's have a look at it shall we?

Hobo Setup Wizard
Do you want to start the Setup Wizard now?
(Choose 'n' if you need to manually customize any file before running the Wizard
.
You can run it later with `hobo g setup_wizard` from the application root dir.)
[y|n] y
=> "y"

Startup
Installing Hobo assets...
create app/views/taglibs/application.dryml
create public/stylesheets/application.css
create public/javascripts/dryml-support.js
create config/initializers/dryml_taglibs.rb
create app/models/guest.rb

First thing is Customizing the test framework. Let's leave that for later! So say n

Test Framework
Do you want to customize the test_framework? [y|n] n
=> "n"

Next up is a name for the user resource. If you;re writing a movie webapp, you may want to use the term "moviebuff" instead of "user".. For now, I'll stick with "user"

User Resource
Choose a name for the user resource: [<enter>=user|<custom_name>]
=> "user"

You know how those fancy sites send an activation email when you create a new account? or those sites which are invite only (Did someone say Google? :P )? Well, using Hobo, you can have both those features with complete ease!

Do you want to send an activation email to activate the user? [y|n] n
=> "n"

Invite Only Option
Do you want to add the features for an invite only website? [y|n] n
=> "n"

Since I'm comfortable with erb, I want to be able to use the erb templating system as well alongside the default dryml system. This can be done in the next step

Templates Option
Will your application use only hobo/dryml web page templates?
(Choose 'n' only if you also plan to use plain rails/erb web page templates) [y|
n] n
=> "n"

Hobo Rapid
Installing Hobo Rapid and default theme...
create public/javascripts/hobo-rapid.js
create public/javascripts/lowpro.js
create public/javascripts/IE7.js
create public/javascripts/ie7-recalc.js
create public/javascripts/blank.gif
create public/stylesheets/reset.css
create public/stylesheets/hobo-rapid.css
create public/hobothemes/clean
create public/hobothemes/clean/images/101-3B5F87-ACD3E6.png
create public/hobothemes/clean/images/30-3E547A-242E42.png
create public/hobothemes/clean/images/30-DBE1E5-FCFEF5.png
create public/hobothemes/clean/images/300-ACD3E6-fff.png
create public/hobothemes/clean/images/50-ACD3E6-fff.png
create public/hobothemes/clean/images/fieldbg.gif
create public/hobothemes/clean/images/pencil.png
create public/hobothemes/clean/images/small_close.png
create public/hobothemes/clean/images/spinner.gif
create public/hobothemes/clean/stylesheets/clean.css
create public/hobothemes/clean/stylesheets/rapid-ui.css
create app/views/taglibs/themes/clean
create app/views/taglibs/themes/clean/clean.dryml
create public/hobothemes/clean-sidemenu
create public/hobothemes/clean-sidemenu/images/100-ACD3E6-DBE1E5-H.png
create public/hobothemes/clean-sidemenu/images/100-DBE1E5-FCFEF5-H.png
create public/hobothemes/clean-sidemenu/images/300-3B5F87-ACD3E6-H.png
create public/hobothemes/clean-sidemenu/images/spinner.gif
create public/hobothemes/clean-sidemenu/stylesheets/clean-sidemenu.css
create app/views/taglibs/themes/clean-sidemenu
create app/views/taglibs/themes/clean-sidemenu/clean-sidemenu.dryml

Front Controller
Choose a name for the front controller: [<enter>=front|<custom_name>]
=> "front"
Installing front controller...
create app/controllers/front_controller.rb
create app/helpers/front_helper.rb
invoke test_unit
create test/unit/helpers/front_helper_test.rb
invoke test_unit
create test/functional/front_controller_test.rb
create app/views/front/index.dryml
remove public/index.html
route match 'search' => 'front#search', :as => 'site_search'
route root :to => 'front#index'
Installing 'user' resources...
create app/models/user.rb
invoke test_unit
create test/unit/user_test.rb
create test/fixtures/users.yml
insert app/models/user.rb
create app/mailers/user_mailer.rb
create app/views/user_mailer/forgot_password.erb
invoke test_unit
create test/functional/user_mailer_test.rb
create app/controllers/users_controller.rb
invoke test_unit

OK, it's all done. Let's take the site live shall we? Let's migrate our database schema to MySQL. As it;s been throughout, it's a completely hassle-free process. Just choose your database migration option as 'm'.

DB Migration
Initial Migration: [s]kip, [g]enerate migration file only, generate and [m]igrate: [s|g|m] m
=> "m"
Migrating...
rake db:setup
(in C:/Press_Play/Press-Play)
C:/Press_Play/Press-Pla/db/schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead
alter C:/Press_Play/Press-Play/config/application.rb to limit the frameworks that will be loaded

---------- Up Migration ----------
create_table :users do |t|
t.string :crypted_password, :limit => 40
t.string :salt, :limit => 40
t.string :remember_token
t.datetime :remember_token_expires_at
t.string :name
t.string :email_address
t.boolean :administrator, :default => false
t.datetime :created_at
t.datetime :updated_at
t.string :state, :default => "active"
t.datetime :key_timestamp
end
add_index :users, [:state]
----------------------------------

---------- Down Migration --------
drop_table :users
----------------------------------
create db/migrate/20110326174912_initial_migration.rb
rake db:migrate
(in C:/Press_Play/Press-Play)
== InitialMigration: migrating ===============================================
-- create_table(:users)
-> 0.2700s
-- add_index(:users, [:state])
-> 0.2450s
== InitialMigration: migrated (0.5180s) ======================================


Next up, the internationalization (I18n) option

I18n
The Hobo supported locales are de en es it pt-PT ru (please, contribute to more
translations)
Type the locales (space separated) you want to add to your application or <enter> for 'en':
=> "en"
create config/locales/hobo.en.yml
create config/locales/app.en.yml
remove config/locales/en.yml

Hobo even asks you if you want it to set up a git repository for your new project and git init it!

Git Repository
Do you want to initialize a git repository now? [y|n] n
=> "n"

Process completed!
You can start your application with `rails server`
(run with --help for options). Then point your browser to
http://localhost:3000/

Follow the guidelines to start developing your application.
You can find the following resources handy:

* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/

That's it! Really! Don't believe me? Check it out for yourself. Navigate to the folder Press-Play


C:\Press_Play>cd Press-Play

C:\Press_Play\Press-Play> rails server

C:\Press_Play\Press-Play>rails server
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

Fire up your browser and key in http://localhost:3000 . And if everything has gone well, you should see:


Yeah, a site with user authentication, individual profiles and hashed passwords all ready for you, and you haven't written a single piece of code yet! The first account created is given administrator priviledges, and priveledges of all other accounts are decided by this account.

Now it's all about customizing it as per your preferences... Check out some of the sites that were born exactly as your project right now: http://hobocentral.net/gallery/ ... Amazing eh?

I'd strongly suggest that you download Rapid Rails With Hobo, a free ebook of Hobo tutorials. Examples in the book make use of an older version of Hobo, so commands may not work out of the box, but it's still an excellent read! Also check out the Hobo cookbook for ideas on what can be achieved using Hobo.

Have fun with Hobo! :)

PS. The original plan was not to post on LoN this entire semester (a hiatus of sorts), but I just couldn't keep myself away! :)

2010 - The Best Year Of My Life (So Far!)

OK, this is my officially my last post for 2010, a year that I shall cherish as the best year of my life (so far)! Tonnes of awesome stuff happened in the 12 months that passed by, both on screen and off of it!

As always, end-sem/end-year is a time of nostalgia for me, and looking back at the year that's gone by, here's a list of some crazy stuff that happened this year in the Life Of Navin!


The People: Sooo many awesome people I've met this year.... I mentioned some of them in this earlier blog post, but they all certainly deserve a second mention! The world is so extremely large, yet so small, at the same time. Both on and off-campus, I met the good, the bad, and the plain weird, and really connected with people on so many different levels. Reconnected with old friends, got back in touch with old crushes, made new enemies... what more could I ask for?

February 2010
: One word: AWESOMENESS (Why? More Why? More More Why?)

My Semester Bucket List: Ended up managing to complete 14 of the 20 things listed! Could've probably done a few more, but I'm happy with what I've got! :)

The Politics: In a single year, I feel like I've taken the leap into politics, perhaps one of the reasons being the fact that I was elected General Secretary of the Computer Science students body CURSOR. I had a weird confrontation with some friends (well, I only knew one of them), who're members of the Students Wing of a certain famous political party, over the post of University Rep of college. I still don't know exactly who our University Rep is (I've heard it's some guy from Civil who is there as a puppet representative), but I seriously hope he/she is fit for the post, because it is a post of major responsibility, and the solutions to quite a few problems in our college can be addressed only by him/her.


Random Bullshit I'm Proud Of: Tonnes of stuff to list here:
  • Scoring a mark (yes, singular) in an internal test
  • Walking around campus at 5 in the morning
  • Staring at a PC monitor blankly for 3 hours with an awesome friend by my side
  • Discussing "proper" Rock music with a girl
  • Speaking to someone on the phone for over 2 hours straight
  • Managing the whims and fancies (some of them legitimate) of an entire class to pull of an awesome inauguration ceremony for CURSOR
  • Downloading the entire discography of multiple bands, just because I like 1-2 songs by them
  • Being woken up by a kick on my butt.... and a hard one at that!
  • Being woken up by her phone call
  • Waking her up with an early morning phone call
  • Quitting Facebook
  • Travelling all alone to Pune for a conference
  • Being a part of Technix 4.0, PhotoFlare, Twestival Goa, Tandav etc.
  • Getting CLUSTR off the ground (More on this next year!)
  • Getting my Drivers License
  • Getting thrown out of the college library
  • Being called a Casanova (yeah, me! :P)
  • The crazy Kachori eating session me and some friends had on campus
  • Sleeping in one of my department labs for an hour or so just before Technix
  • Managing to remain smoke-free and drink-free (It's a challenge in college, really is!)
  • The Random behind-the-scenes help provided by friends and teachers, which unfortunately very few people know about and appreciate
  • Some other stuff that remains with me for the time being! ;)
All the stuff that happened in 2010 has affected me, for good or for bad, and has helped me become the person I am today. 2010 has delivered all that could be expected from it. 2011, you have have your work cut out for you! Hope you manage to deliver! :)

P.S. I leave on a family tour on the 24th, and return on the 2nd! So here's wishing everyone a Super Awesome Christmas and a Mindblastingly Kickass New Year! :)

Venn I Suck, I Suck!

The reason why I hate John Venn is the intersection of childhood irritation his diagrams caused and Venn diagrams on Tumblr Always be yourself... unless you suck -Joss Whedon

Kiddin' Around!

Honestly, this post is complete nonsense!
--------------


U me katti no no,
Me no katti u
This all makes no sense to me,
Does this make sense to u?
Me was sleepy bye bye,
So me no msgs see
N when me wake up fresh fresh,
Saw 12 msgs fr me!
Now me to Tanika say say,
Me lyk u very much
Now random fact me say say,
Vodafone was once called Hutch
Now me be saying shit shit,
Infact shit from a bull
Or bullshit as me call it,
Me has gone mad full
If me keep say say bullshit,
Me'll be banned, that's a fact
So me just say say Good Night
to Limbu from my Max

--------------
Poem Backstory:
I'm pretty sure none of the above made sense, so a backstory is definitely necessary!

Basically, I have this extremely crazy, super-awesome, junior friend named Tanika...
Always smiling, eternally blissful, and completely mad (she's easily one of the whackiest friends I have!). She's my 'Baby Pishe', and whenever we talk, it actually is like two kids talking to each other!

Our semester exams are going on (yes, I'm updating my blog during my sem exams! :) ), and we both have exams on alternate days, but I have papers on days she doesn't (and vice versa).

Right after my first paper, once I got back home, I did what us half-baked engineers do best during exams, sleep! And when I woke up, there were over a dozen messages from Tanika, reminding me to wish her Best of Luck for her exams the next day!

Why would someone remind me that? Well, simply because I have memory of a goldfish... I actually had a friend who called me up at 11:55 one night, just to remind me that it was her birthday the next day (in 5 mins) and I'd promised that I'd call her up at midnight! :)

Anyway, the last message from Tanika was:

me no lyk u.. u no nyc.. u no wish me afta yaad karofying olso..
me u angyy.. me no tok u.. me u, katti fu!! :( :( :(

If you grew up in India and still don't know what 'Katti Fu' is, you may as well go hang yourself!

Anyway, my reply to her message is what you read above!

I know, even with this huge backstory, it's still nonsense, but I totally felt like a kid while typing that out! And that's exactly the kind of craziness I needed to get me back to studying my prehistoric portion!

Ah, One more thing. Me and Tanika are connected by our weird phones.... I have a Micromax, and she has a Lemon (Limbu!) cellphone ... hence the last line! :)

Related: God(dess) Mode

Prologue

Finally after all these years, here's to the beginning of what was there, what is there and hopefully what will remain!! So here are my thoughts & words -Online!!

Blog Archive