How to populate your table with default values in rails

I have a Roles table with :name and :long_name columns. I have only 4 types of roles, with name i.e. short name and long name; :tm => Team member, lm => Line manager, :hr => Human resource and :admin => Administrator. In order to populate the values in my Roles table, all I need to do is put the logic in my db/seeds.rb file and run the rake db:seed command.

seed.rb —

role_collection = { 
  :hr => 'Human Resource', 
  :tm => 'Team Member', 
  :lm => 'Line Manager', 
  :admin => 'Administrator' 
role_collection.each do |key, value|
  @a_role = { :name => key.capitalize, :long_name => value }

rake db:seed


Technology Hype

Okay I admit it, I am very hyped about the hottest programming language out there and basic instinct is always to dive in head first (not very wise). As I said in my previous post, that I will be rewriting my uni project in rails, just before the dust settled, I came across this post which literally smashed my head against a brick wall. FKS stick to your goal damn it! I haven’t dived deep into my current language (C#), that I wanna pick another due to my technology junkie(ness), doing this won’t take me far, so I revert my decision to rewrite the project in rails and stick to the original plan (when it’s done, I’ll blog about it)

Why am I posting this incosistency? Well because I am me, and I have this challenge.

Thought Trails

I have been looking into ruby and rails for a while now and most say, the community ROCKS. One very cool thing about the ruby community, appart from the fact that they are totally cool (cool might mean something else to you), they have a strong focus on TDD and Agile Methodology in general. I’ve been mock about re-writing my uni project using ruby on rails (only done the class library so far) in order to gain some hands on experience in it, MySQL and GIT (of which people have been raving about these days). I am beginning to wonder whether coding with the help of intellisense in visual studio is actually making me lazy or more productive. There are camps that support the benefit of intellisense and others that don’t. Personally I like intellisense, but have I become too used to it that picking up a new language without any intellisense is scaring me away from my comfort zone? Have I become a woosie?

Well to prove to myself that I ain’t no woosie, I will rewrite the class library and site using rails and TDD methodology. FKS (For F*ck Sake) I am disciplined and I eat challenges for breakfast, lunch and dinner.