Ruby, Rails, and Rinari

Rails Notes

http://farm4.static.flickr.com/3184/2886745454_222717cf27_m.jpg

Rails commands


rails commands
rails g call generator
rails c rails console
rails db rails dbconsole
rails new create a new rails application

Rinari commands

Rinari is a cool Ruby on Rails minor mode for Emacs.


Key binding Rinari Command
C-c ; f find command
C-c ; f c Find Controller
C-c ; f m Find Model
C-c ; f v Find View
C-c ; c rails console
C-c ; d dbconsole

ruby stuff

# loop 10 times
1.upto(10) { |i| print i, ", " }
puts " "
# open file and read lines
open("/home/bart/rubys/namesdata.txt").readlines.each do |line|
    str = line.split(" ")
    # print all but last 4 fields
    names = str[0..-5]
    puts names.join(" ") + ": " + str[-3].to_s

end


Tags:

Category:

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.