Archive for April, 2008
ruby rake
ruby is make like utility.Make utility makes a install with all the options and config you want .Rake is similar to Make
within a rails application go to that directory ask the rake to tell about itself
rake -T
rake rails:freeze:gems
rake doc:rails : will install the rdoc for the rails –> the activerecord#find etc…in the html format in [...]
Ruby : Math
Math is a module which has a lot of useful Methods.
To convert from one class to another just call the class name followed by parameter.
Integer(field)
Float(field)
String(field)
All other method are applied on the object itself like 3.div 3 or 12.divmod 5 which divides and gives the balance. or you can remainder to get the remainder alone.
you [...]
rails basics
render(:controller=>’say’ ,:action=>’hello’)
render(:partial => ‘form’)
redirect(:controller=>’say’ :action=>’hello’)
link_to(‘mylink’,:controller= >’say’,:action=>’hello’,:id=>1)
params.inspect
logger.warn,logger.error,logger.info,logger.fatal
(ActionView only) debug(params)
( FormHelpers only)
<input type =’text’ name=album[title]/> can be written as
<%= form_tag(:action=>’create’) do %>
<%= text_field(:album, :title) %>
<%= datetime_select(:album, :release_date) %>
<%= submit_tag(“name of button”) %>
<%= end %>
form_tag
form
error_messages_for(:album) —> debug(album.errors)
validates_presence_of :artist
before_filter(controller) :method nly/:except =>[]
after_filter(controller) :method nly
Model inherits from ActiveRecord::Base which has methods like find,find_by_id,find_by_sql,save,update,destroy
Controller is inherited [...]
ruby gems
http://docs.rubygems.org/read/book/2
gem -v : would give the version
gem list –local : list of all gems in the system with thier version number.if there was 2 version then it would give them in descending order
gem outdated : would give list of gems which are outdate
gem update : would update all the gems.
gem update –include-dependencies –no-rdoc
gem cleanup : [...]