I get asked frequently about how people should become a Ruby on Rails developer -- that's such a broad range of topics it's hard to give just one path. You not only need to learn how to program, but you need to master Ruby, JavaScript, databases, TDD, and at least a little bit of graphics design (CSS).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Brain | |
def think; end | |
def code ; end | |
alias evaluate think | |
alias refactor code | |
end | |
brain = Brain.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
has_many :orders | |
attr_accessor :name | |
attr_accessor :devise | |
end | |
class Book | |
has_many :line_items | |
has_many :orders, through: :line_items | |
attr_accessor :title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order | |
has_many :line_items | |
has_many :cupcakes, through: :line_items | |
def total_price | |
totals = line_items.map(&:total) # 50, 50, 100 | |
totals.sum | |
totals.inject(:+) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
attr_reader :front_wheels | |
def initialize | |
wheel = Wheel.new | |
wheel2 = Wheel.new | |
wheel3 = Wheel.new | |
wheel4 = Wheel.new | |
@front_wheels = [wheel, wheel2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_brigade = {} | |
my_brigade[:Chef_de_Cuisine] = "the Head Chef in charge of the kitchen" | |
my_brigade[:Sous_Chef] = "2nd in Charge to the Chef de Cuisine" | |
my_brigade[:Saucier] = "who Prepares sauces, soups, and finishes dishes" | |
my_brigade[:Rotisseur] = "the Grill cook who prepares meat dishes" | |
my_brigade[:Poissonnier] = "the Cook in charge of fish dishes" | |
my_brigade[:Entremetier] = "the Cook in charge of Vegetable and Pasta Dishes" | |
my_brigade[:Garde_Manger] = "the Cook who prepares cold dishes, salads, and charcuterie" | |
my_brigade[:Tournant] = "the Cook who helps in any station as necessary" | |
my_brigade[:Patissier] = "the Cook who prepares deserts and sweet dishes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="AngulaRails" ng-controller="WidgetController" ng-init="setWidget(<%= @widget.to_json %>);"> | |
<%= form_for @widget, id: "widgetForm", html: { name: "widgetForm", "novalidate" => true, "ar-submit" => true } do |f| %> | |
<% if @widget.errors.any? %> | |
<div class="alert alert-danger"> | |
<h4><%= pluralize(@widget.errors.count, "error") %></h4> | |
<ul> | |
<% @widget.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
greenvilleJS.controller('wayCoolCtrl', ['$scope', '$q', function ($scope, $q) { | |
$scope.address = ""; | |
$scope.mapMarkers= []; | |
$scope.zoom = 8; | |
$scope.geoCoder = new google.maps.Geocoder(); | |
$scope.mapCenter = function() { | |
return $scope.map.center; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Automobile | |
@@autos = [] | |
def self.count | |
@@autos.count | |
end | |
def self.autos_for_model(model_name) | |
@@autos.select{|auto| auto.model == model_name} |