Gems - Heroku - Rails - Semantic Web - See also - To do
- Ruby in Twenty Minutes
- Conseils pour utiliser Ruby, RVM, Passenger, Rails, Bundler, … en développement by Jérémy Lecour, 2010
- Episode 159: RSpec vs TestUnit, The Ruby Show April 2011
- Behavior Driven Development Using Ruby (Part 1) by Gregory Brown, O'Reilly Media 2007
- Ruby Learning Test #1: Are You There, World? by Mike Clark, Clarkware 2005
- "we used the language as a tool to explore itself. In the same way that a test is better than a specification, the language is better than a description of the language."
- Learning Ruby via Cucumber, Obtiva 2010
- Business Readable DSL by Martin Fowler, 2008
- Cucumber Making BDD fun
- note the quite sarcastic
examples/i18n/fr/
scenario
- Cucumber-Rails for Rails3
- Introduction to Outside-in Development with Cucumber by Charles Maxwood, 2010
- What's in a Story? by Dan North, DanNorth.net 2007
- Metaprogramming - A New Way to Shoot Yourself in the Foot by Brian Muller, SC Ruby Conf 2008
To explore
Gems
Heroku
Explored
remarks
- make sure to keep on checking for the console and the logs
- locals errors are less "strict" than on the server
- pay attention to specificity of syntax regarding databases, what works locally might not work remotely
Rails
Design
Internationalization
- Rails Internationalization (I18n) API, Ruby on Rails Guides
- #138 - I18n, Railscasts 2008
- use
set! intl.accept_languages=fr,en,en-us
to quickly switch languages in Vimperator
- Chinese zh
- Rails I18n From The Trenches by Clemens Kofler, 2009
- see also #rails-i18n on freenode
- note that the filesystem, the code repository and the push to the other system have to be properly configured and support UTF8
- e.g. problem of Chinese zh.yml on Heroku
- utf-8 file seems to be ignored, falling back to the default locale
- note that this based on the saved file format, not its content
- fixed by saving to UTF-8 encoding without BOM (cf Wikipedia:Byte order mark)
- I18n Backends #256, Railscasts March 2011
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
by William Sobel, UC Berkeley RAD Lab 2007
- Part 1: Hello World
- ~min27 table name are singular and with only the first letter capitalized
- not CamelCase
- from learning keywords to learning conventions
- ~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
- ~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
- basically using a view through a partial
- with JavaScript encapsulating XHR using form_remote_tag
- with a controller returning just the value to replace value
- based on Prototype
- mention of Scriptaculous in JavaScript used before
- unit test directly in Ruby
- see also Ajax on Rails - Build Dynamic Web Applications with Ruby by Scott Raymond, O'Reilly Media 2007
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
- creation of the app
- scaffolding
- helpers
- routing via
config/routes.rb
- check available routes via
rake routes
- going further than URLRewrite
- see http://guides.rubyonrails.org/routing.html
- public/ provides the default route "as-is"
- thus useful for static content including stylesheets, libraries and images
- preparing for an API through routing but also XML rendering
rails console
for tests
- partials as a snippet of re-usable code
rails server
gives tons of information
- classical httpd information (parameters, timestamp, IP, ...)
- query time split by render, view, active record
- DB query used
- link between models
- naming convention matters
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
- wagn.org RoR semantic wiki
- activerdf.org library for accessing RDF data from Ruby programs
- RDF.rb Linked Data for Ruby
- RDF.rb, semanticweb.org
- public domain Ruby library for working with RDF data.
- Getting data from the Semantic Web (Ruby), semanticweb.org
- tutorial is for programmers used to building software on top of non-Semantic-Web data sources: using screen scraping techniques, or using APIs that return XML, JSON, CSV etc.
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
- use code repository to see the list of symbols used over time
- ideally to visualize learning
- should be removed
- personally defined functions related to each app, e.g.
def create
and such
- code from gems
- to move to Programming in general
- yet probably the best dataset I have to far
- 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
- looking up in the doc/stackoverflow/search engines/code repo
- a la http://sourcerer.ics.uci.edu or http://ase.csc.ncsu.edu from Programming
- see also http://ginzametrics.com/how-search-affects-language-design.html
- add an activities session
- link to RailsCampParis3
- 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
- metaprogramming
- Ruby and Vim
- Sinatra DSL for quickly creating web applications in Ruby with minimal
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.