#Grouping#
prods = Product.group(:price).count
Returns
puts prods
=> {573=>3, 574=>4, 575=>6, 576=>4}
The group method returns a hash of all prices, along with the count of each price. For example, there must be 3 items priced at 573
#Grouping#
prods = Product.group(:price).count
Returns
puts prods
=> {573=>3, 574=>4, 575=>6, 576=>4}
The group method returns a hash of all prices, along with the count of each price. For example, there must be 3 items priced at 573
#Mixing and Matching Queries#
puts Product.where(:price => 5).
where(:name => "apple").
order(:created_at).
limit(55).
joins(:users).
where(:user => {:name => "richard"})
##Each method takes the output of the previous and adds to it##
#Arrays# ###Using the Docs###
[1,2,3,4].each {|x| puts x + 1 }
2
3
4
5
=> [1,2,3,4]
#Fundtimentals of programming
###What is programming?
The art of programming is to take a larger idea and break it apart into smaller ideas.
Computers will do exactly as you tell them, so you need to make sure your instructions are right.
#Novation Launchpad for Keyboard shortcuts
###4 Score and 7 years ago, we used keyboard shortcuts, or something...
Something I've always struggled with is remembering keyboard shortcuts. I'm not sure why. Software I grew up using, they have become engrained in memory. I'll never forget the Photoshop 6 shortcuts that became etched in my young impressionable mind. I also dislike using the mouse. It feels so inefficient to move from keyboard to mouse, especially being in flow.
##My brain is too small, helppp!
With the bombardment of great new tools, I've been forced to abandon shortcuts in most applications. This was until my brother showed me a peice of hardware he is using to produce music.
#ActiveRecord Schneems tutorial notes#
##Joins##
class Product < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :products
#Having#
Objective : Find all of the products that have more than 5 duplicate prices
Group & Having
prods = Product.group(:price).having("count(price) > 5")
puts prods
=> [#<Product id: 1743,
user_id: 1363,
M - Model - Our objects, Its the object oriented approach to design and it encapsulates the data in the database
V - View - Presentation layer - It is what the user sees and interacts with - pages/html/css/javascript
C - Controller - Process and respond to events such as user actions and envoke changes to the model and view based on that. Its going to make decisions for us and control what happens
Conventional => Browser <-> Page <-> Database <=> Page <=> Browser
#Javascript Notes
###Core Concepts -
Javascript is a programming language. Often times javascript is referred to as a scripting language, but most programmers dismiss this and argue javascript is a programming language.