webbing exchange and Semantisize and Free Online Course in Ruby on Rails Powered by Google App Engine

Monday, August 11, 2008

Rails !

hmm ... someone pointed out that I ripped this from a site or the help file or something. Well, I did not say I wrote it right? Anyway, the list below is available elsewhere, but I put it here for the benefit of any Rails developer wannabe who happens to stumble onto my blog....

Some useful rake and rails 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 migration AddNewTable

ruby script/generate plugin PluginName

ruby script/generate mailer Notification lost_password signup

ruby script/generate web_service ServiceName api_one api_two

ruby script/generate integration_test TestName

ruby script/generate session_migration


Find:


find(42) # object with ID 42

find([37, 42]) # Array with the objects with id 37, 42

find :all

find :first,

:conditions => [ "name = ?", "Hans" ] # finds the first record with

# the matching condition


more parameters for find:

:order => ‘name DESC’ # sql fragment for sorting

:offset => 20 # starts with entry 20

:limit => 10 # only return 10 objects

:group => ‘name’ # sql fragment GROUP BY

:joins => ‘LEFT JOIN …’ # additional LEFT JOIN (rarely used)

:include => [:account, :friends] # LEFT OUTER JOIN with these model

:include => { :groups => { :members=> { :favorites } } }

:select => [:name, :adress] # instead of SELECT * FROM

:readonly => true # objects are write protected


Migration:


rake db:migrate

rake db:migrate VERSION=14

rake db:migrate RAILS_ENV=production


Calculations:


Person.average :age

Person.minimum :age

Person.maximum :age

Person.sum :salary, :group => :last_name


3 comments:

Arasu S.P said...

EMmm... This copy might plagiarized from a mini Rails ebook reference. Its ok when people make use of your blog site to feed their brain. Appreciate you with handful of shit. (Sign of show gratitude). Here goes a dung beetle rolling a load of shit.

Arasu S.P said...

Its seems a drawback for a new idiots to learn Ruby on Rails. Spend massive time on surfing on Internet

analogkid said...

erm ... did i say it was mine? nope, ripped it off somewhere. hey, it's open source.