Gems - Heroku - Rails - Semantic Web - See also - To do

To explore

Gems

Heroku

Explored

remarks

Rails

Design

Internationalization

A Guide to Testing Rails Applications, Ruby on Rails Guides

Meet Rails 3, PeepCode

Part I

  • ri for in-line documentation
  • config/developments
  • yield passes on the content of the action
    • useful to rewrite a layout view for a specific controller rather than the default application one
  • recomending to use _path in views and _url in controllers
  • active code generation as code generated in memory as the program runs
  • correcting a model
    • rails generate --force option to replace files
      • problematic for migration files
    • rails generate migration AddThis
  • Tablename.where(:column => "Value")
  • reload! in rails console to insure that changes are applied
  • scope and the proper place to define queries in the model files

Part II

  • partials
  • helpers
  • rake db:seed to run db/seeds.rb
    • no output, has to be done manually via puts
    • that will be rolled-out during production thus practical for initialization
    • see rake -T db for more related commands
  • defining a rake script in lib/tasks/app.rake
    • that must be called manually thus practical for tests as sample data

Ruby on Rails Intensive 1-Day Course

by William Sobel, UC Berkeley RAD Lab 2007

  • Part 1: Hello World
    • ~min27 table name are singular and with only the first letter capitalized
    • ~min45 comparing migration to versionning for database schema
    • ~min52 1 argument means it is the id (by convention)
    • ~min72 on runner to manipulate an application from the command line
  • Part 2: Just Enough Ruby
    • ~min2 a programming language is a user interface
    • all variable are objects and thus have functions attached to them
      • this also applies to classes, useful for metaprogramming
        • e.g. String.instances_of? Class returns true
      • object.methods and Class.methods display the list of available methods
    • ~min25 every class and method can be overloaded
    • ~min28 instances variables are only accessed through their class
      • thus required method
    • ~min85 detailing the rails stack
      • and comparing to the J2EE call stack
  • Part 3: Basic Rails
    • find_by_attribute_name, find_by_attribute_name_and_other_attribute_name (by convention)
      • thus risk of conflict using by_ or and_ in table names
  • Part 4: Advanced Active Record
    • create = build + save in the DB
    • join tables have table name they join ordered by alphabetical order (convention)
  • Part 5: AJAX and Testing

Discovering OmniSocial by Icelab

  • gem install [package name] to fetch and install a library
    • bundle install to add it to the path
    • gem list --local to display what gems are available locally
  • editing GemFile in the application folder
    • adding gem '[package name]' to include it
    • bundle to fetch all the packages and make it available in the application
  • extended the user model
    • rails generate migration DescOfMyModelModification
    • vim db\migrate\...DescOfMyModelModification.rb to add or remove fields (with self.up 'and self.down to allow rollbacks
    • rake db:migrate to apply it to the development version, test it then commit, push and migrate remotely

Install on Windows

  • Ruby installer from http://rubyinstaller.org/downloads/
    • without a space in the path, e.g. not C:\Program Files
    • ruby gems\setup.rb
    • gems install rails
    • adding sql3lite.dll with the proper version to the Ruby\bin directory
      • hooks for SQLlite comes by default assuming SQLlite library is present
  • install Git for Windows
    • make sure that you have pageant running and that the key is properly loaded
    • especially for Heroku
    • msysGit is not required, especially if you already plan to install MinGW
    • consider ANSICON for a replacement console when colors matter (e.g. Cucumber)
  • install MinGW
    • also with a path without space
    • including MSYS with C/C++ and compilation tools
  • install DevKit
  • make sure Ruby is properly running in MinGW environment
  • install gems which do not provide binaries for Windows
    • e.g. Cucumber through JSON
  • install plugins from github
    • rails plugin install https://github.com/username/projectname.git (rather than git@github.com:username/projectname.git syntax)
      • note that this is probably due to restricted Internet access, forcing to use http/https rather than directly Git

Following Getting Started, Ruby on Rails Guides

Remarks

  • objects that are created following a model are not updated as the model is updated
  • db/schema.rb represents the database
    • yet association are described in app/models/ and are relying on foreign keys
      • how does db/schema.rb gets updated knowing rake db:migrate is not run after edition of association in the model file?
    • see Updating the schema section of A Guide to Active Record Associations, Ruby on Rails Guides
      • "If you create an association some time after you build the underlying model, you need to remember to create an add_column migration to provide the necessary foreign key."
  • name should be informative by taking into account their function relative to the other model
    • "In any case, Rails will not create foreign key columns for you. You need to explicitly define them as part of your migrations."
    • e.g. User can become :author for a blog post
  • name must be pluralized, including variable or class names
  • syntax
    • not understood
      • ?
    • unsure *** potential explanation%
      • => :this pass a hash value
      • |f| to define a temporary object available within that scope
    • understood
      • <% execute the code within this template without displaying the returned value
      • <%= execute the code within this template and display the result
      • < for class inheritance
      • def to define a function
      • [...] to define or use an array
      • {:minimum => 5} conditional
      • @array this.function helper_name
  • "magic" under the hood makes it powerful yet tricky
    • naming convention, when should scaffolding or generate be used, etc
    • all efficient helpers *_* with complex name remains unknown
  • scope not understood
    • what functions is available to which other?

To explore

Semantic Web

See also SemanticWeb

See also

  • Programming
  • apply Cognition#OptimalLearningClosure and refrain from watching a video or reading a chapter of a book without first having used it in code
  • my side work at ShanghaiExpat on metaprogramming for a PHP CMS
  • french community
    • Ruby France site de l’association Ruby France.
      • also with #ruby.fr and #rubyonrails.fr on freenode
    • Railsfrance.org communauté francophone des utilisateurs de Ruby on Rails

To do

  1. use code repository to see the list of symbols used over time
    1. ideally to visualize learning
    2. should be removed
      1. personally defined functions related to each app, e.g. def create and such
      2. code from gems
    3. to move to Programming in general
      1. yet probably the best dataset I have to far
  2. find a tool (like an IDE plugin) to underline a piece of code and display explanations about the syntax, prototypes of functions from the doc, similar examples from code repository, etc
    1. looking up in the doc/stackoverflow/search engines/code repo
    2. a la http://sourcerer.ics.uci.edu or http://ase.csc.ncsu.edu from Programming
    3. see also http://ginzametrics.com/how-search-affects-language-design.html
  3. add an activities session
    1. link to RailsCampParis3
  4. BDD
    • Behavior Driven Development Using Ruby (Part 3), O'Reilly Media 2007
      • ability to respect DRI through RSpec it_should_behave_like
      • "It's pretty easy to see which classes were and were not developed using BDD. The neat thing is that RCov does a line-by-line output of your code, highlighting lines that were not run in red"
    • many more articles read during WithoutNotesApril11

Note

My notes on Tools gather what I know or want to know. Consequently they are not and will never be complete references. For this, official manuals and online communities provide much better answers.