ruby on rails

A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

https://rubyonrails.org/

Starky and Hutch sessions

2024-11-18

Questions

2024-11-07

Questions

class CreateBooks < ActiveRecord::Migration[7.2]
  • Like an alias.

  • see Dir[]

  • Foo.new { |f| ... end } purpose compared to “classic” imperative approach?

book = Book.new do |b|
  b.title = "Metaprogramming Ruby 2"
  b.author = "Paolo Perrotta"
end
# vs
book = Book.new
book.title = "Metaprogramming Ruby 2"
book.author = "Paolo Perrota"
  • It can be useful for constructor with mandatory arguments.
  • It’s also more performant in some situations:
def foobar
  # A is memory hungry
  a = A.new
  # do something with a
 
  # long method...
end
# a is only release here
 
# VS
 
def foobar
  A.new do |a|
    # do something with a
  end
  # A will be released
 
  # long method...
end

2024-10-28 - ice breaker

  • Session formats:
    • Duration: 1 hour per week, on Mondays, and we can shorten the session if it’s too long.
    • Read a section from Rails guides and check together in doctolib monolith code base to illustrate the principle.
      • Primary subjects to check out: model + controllers + active job
    • Also possible review together some code.
    • Progress status of the project kubetailrb.
      • This project will not highlight the features of rails’s ActiveRecord. Either find another project or find a way to use the ActiveRecord with kubetailrb.
    • Q&A

Questions

  • Are the ruby exercises from uniq are relevant or not?
    • Teck Wan Wong doesn’t know as he didn’t do the tutorials on uniq.
  • Does ruby on rails at doctolib differ a lot from the framework?
    • Tutorials on the internet can make me understand doctolib.
    • Use react + slim (for SEO) for frontend.
  • Concurrency in ruby?
  • We can install a gem with --user-install. What’s the difference without this flag? Is it useful if I’m using rbenv?
    • It should be most likely about precedence, i.e. ruby would take from the user installation directory before the installation directory.

Tips

  • Use bundle open ${gem_name} to open the source code of the gem.

Resources