Skip to content

Instantly share code, notes, and snippets.

require 'faker'
# Create Users
5.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: Faker::Lorem.characters(10)
)
user.skip_confirmation!
@JoseJRVazquez
JoseJRVazquez / gist:11375777
Created April 28, 2014 15:40
A seed.rb file
require 'faker'
# Create Users
5.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: Faker::Lorem.characters(10)
)
user.skip_confirmation!
So here they get deep into MVC, and what it means. Controllers are tightly woven with views, and so when you spit out the generate command it populates both.
Not sure what to say, standard setup and deployment of barebones rails app like before.
@JoseJRVazquez
JoseJRVazquez / First Rails App
Created April 24, 2014 15:02
My work on my First Bloccit App
I admit it, I skipped a step. My bad.
Now, here is the rub. I have already done the setup for an app before this, and this time it ran smoothly as well. The new intrudction is the ASSET PIPELINE, which acccording to the text is as follows:
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB.
Had a bit of trouble uploading to git but was able to fix it manually. Works well now and will make commits
@JoseJRVazquez
JoseJRVazquez / Advanced Classes
Last active August 10, 2018 20:12
My Lesson in Advanced Classes in Ruby
Ok, so Inheritance
its not just for young white dudes waiting for their grandparents to fucking keel over at 82.
In ruby, Inheritance allows one class to inherit from another class attributes and behaviors (methods) that it didnt have before. The inheriter, much like a young white male, is the child class. The class that it inherits from, rather than being his old money grandparents, is the Parent Class. The lesson says Inheritance is designated with a < symbol, for example:
class Daughter < Father
end
wow, quick right. So for that, the daughter is getting methods from the father. Simple right. But lets go deeper and se how fucked up this can really get for those of us in the cheap seats.
LOOPS: Doing shit over and over again since computers first started
SO the lesson defines it as the following:
A loop is a programming construct that is used to "step through" a collection of objects. The proper way to express this in programming terms is to say that a loop "iterates over a collection." Another way to think about loops is that they instruct a computer to do a task multiple times. As you know, an Array is a collection of objects, so you could use a loop to iterate over an Array. While iterating over a collection of objects, a loop can be programmed to do things to each object in the collection.
Each
There are different ways to program loop constructs in Ruby, but the two most common are each and while. The each method is called on a collection, like an Array. Try the following in irb:
so....
looks like that while its all fine and dandy for someone to have a getter and setter attribute for a class, so you can enter data and spit it back out, the question becomes what if you want a vlue set by default...for whatever bs reason.
The exmaple given is as follows:
class President #defines class
def initialize #defines method
p "Hello, I'm an instance of the President class!" #the action that is done or info entered by default
end #close the method
Now I know what classes are in CSS and HTML. But now for ruby....ouch
So, according to the lesson, Ruby is an Object-Oriented language. In an OO language, objects communicate with each other via messages. Thats to say, messages containing instructions are sent to objects, then something happens. Here's an example they give:
numbers#This is a variable = [1,2,3] #This is the Object
numbers.length #Length is a method with a very explicit set of instructions, which for this is to query the object for its length
#=> 3 #the answer the object returns from the method that asked the question in the first place (its a nosey bitch, MYOB)
SO in this, its declaring a variable named NUMBERS and setting it equal to an array consisting of 1, 2 and 3. Our numbers array is in fact, an object. On the next line, we are sending our numbers object a message. The message is basically asking the object for its length. As you know, length is also a method, but in the abstract it's really just a message with an explicit set of ins
ok, brief overview
1) true and false, do not need quotes, as they are psudo-variables and native ruby values
2) || is the same as saying "or", and && is the same as saying "And" in a method argument
3) ou can use elsif on mlutple lines, or try using difference arguments in parenthesis
4)
more to follow
SO sometimes we have to as a question, and have a result based on that answer. For example
"I Mary doesnt have two shoes on, ask her 'why'"
For assignment is the following quesiton is given
"If Mary has more than $5, then give her an apple."
So the following code is given as an example