Understand all the terms in How Ruby method lookup works, in particular: include extend singleton class prepend Do you understand why object.extend(SomeModule) is the same as object.singleton_class.include...

How does include and extend work together with inheritance? You may also read more about the Ruby Object Model, if all of this is quite confusing to you. Metaprogramming...

Rails Database Best Practices ActiveRecord: Specifying conditions on an associated table Preload, Eagerload, Includes and Joins Battling n+1 Queries in Rails Tips Preventing scopes from loading

...AND title="Foo" Preloading associations When you preload associations with #preload or #includes Rails will make one query for each table: Card.where(title: 'Foo').preload(:user).to_a # SELECT * FROM...

makandra Curriculum

...better matchers Which of the following two lines is better? Why? expect(array).to include(5) expect(array.include?(5)).to eq(true) Custom matchers Write a custom matcher called have...

Consider the following example from the Modularity README: # app/models/article.rb class Article < ActiveRecord::Base include DoesStripFields[:name, :brand] end # app/models/shared/does_strip_fields.rb module DoesStripFields as_trait do |*fields| fields.each do |field|

...Modularity source code and understand how the implementation works. In particular, understand this syntax: include DoesStripFields[:name, :brand] What exactly is included here? How does Modularity enable parameterized modules? How...

...movie form, I should be able to select the inspiring movie. The list should: include all the movies that were released in previous years not include the movie itself

...include a movie that was itself inspired by the movie that is being edited. Traversal In the movie show view, I want to see the "inspiration tree" of that movie...

...functionality to a a new controller, not the movies controller. The movie/actor association should include an attribute for the name of the played character You only need very basic styling...

...version of the same dependency. It can be useful as it allows you to include two libraries that would otherwise not be compatible, e.g. when one relies on jQuery...

makandra Curriculum

...If you are using terminator, bin/term is the easiest way to to achieve this. Include the byebug gem in your Gemfile. This provides debugging for your app.

...for full-stack integration testing. Try and use it Your forked MovieDB should already include a feature that uses a real browser. Add the @javascript tag to your other features...

...a Rails application, your code base will grow a collection of different file types including: Ruby (business logic) HTML fragments (layouts and views) CSS/Sass/SCSS (styles) JavaScript (client-side behavior)

...how can we define a "manifest" or "pack" that defines which files should be included in the build? Can our JavaScripts use import or require to load another file? Fingerprinting...

makandra Curriculum

...difference between class methods and instance methods (def self.method vs. def method) Modules and include Code blocks ("procs", "lambdas") Input and output Simple regular expressions Resources Tutorials

makandra Curriculum

...versions. In this bonus chapter, we want to dive deeper. Common web apps often include static images like icons and application logos next to the dynamically created images versions of...

makandra Curriculum

Read the card Before you make a merge request: Checklist for common mistakes Include the checklist in the description of all future merge requests and try to tick all...

...need to parse the given string of Ruby code. You don't need to include methods from the superclass. You may assume that the given code contains exactly one class...

Learn to create test data effectively using factories. Decouple tests by having each test start with an empty database...

There is no single place to look up documentation for our stack. This card includes some hints where you can find API documentation. You probably want to drag a few...

Best results in other decks

makandra dev

...from prepended modules (Ruby 2.0+ feature) Methods from the object's class Methods from included modules Methods from the class hierarchy (superclass and its ancestors) Example

...have the following class hierarchy: class Superclass def action puts "Superclass" end end module IncludedModule def action puts "Included module" super end end module PrependedModule def action puts "Prepended module...

api.rubyonrails.org

ActiveSupport (since 4.1) includes test helpers to manipulate time, just like the Timecop gem: To freeze the current time, use freeze_time (ActiveSupport 5.2+): freeze_time To travel to a...

Search in all decks