Rake Tasks

rake cache:clear # Clears all cached pages rake db:bootstrap # Loads a schema.rb file into the database and then loads the initial database fixtures. rake db:bootstrap:copy_default_theme # Copy default theme to site theme rake db:bootstrap:load # Load initial database fixtures (in db/bootstrap/*.yml) into the current environment’s database. Load specific fixtures using FIXTURES=x,y rake db:fixtures:load # […]

Read more "Rake Tasks"

Ruby Arrays and Hashes

Came to know about these : Inject method: Say you have an array a1 = [1,2,3,4,5] and you want to sum up the elements, then do this – a1.inject(0) {| sum_so_far, item | sum_so_far + item} This iterates over all the five elements and returns 15. To find the product: a1.injetc(1) { | product, item| […]

Read more "Ruby Arrays and Hashes"

Rails Stuff

Some useful rake commands: rake migrate version=0 rake test:units rake test:functionals rake annotate_models rake db:sessions:clear rake doc:app rake log:clear rake db:test:prepare -> prepares test database with development database schema rake -T #displays all rake tasks with description Generators: ruby script/generate model ModellName ruby script/generate controller ListController show edit ruby script/generate scaffold ModelName ControllerName ruby script/generate […]

Read more "Rails Stuff"

Letz Talk Ruby and Rails

This is about Ruby and of course Rails. So lets get onto Ruby on Rails wagon. These are some things that I keep using these days: To check for empty file field: @image = Image.create params[:image] unless params[:image][:file_data].kind_of? StringIO here params[:image][:file_data] is the hash for image to be loaded. If the file field is blank, […]

Read more "Letz Talk Ruby and Rails"