Friday, October 25, 2013

My Bundler Feature was Merged

My PR to Bundler  was merged!
This fixes the issue: Warn if the same gem (same version) is added twice. bundler/bundler-features#22

Try it out: Open a Gemfile in on of your projects and duplicate one of your gems.
do a bundle install
You should get a warning telling you that you have a duplicated gem and what it is.
This is the warning you'll see:

"Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once. You should probably keep only one of them. While it's not a problem now, it could cause errors if you change the version of just one of them later."
Yay!!

Wednesday, October 23, 2013

New Relic Rocks

So I am here in San Francisco for the Future Stack Conference because New Relic gave Rails Girls a scholarship. Someone else was supposed to come but she couldn't make it and I was next on the list. So New Relic paid for me to fly here, sent a car for me; a fancy, shiny, black car which dropped me off for a 3 night stay at the Grand Hyatt Hotel in Union Sq. My room is amazing. Then I got an amazing goody bag with a cool Future Stack tote, t-shirt, stickers, other swag and a generous food stipend. Wow. I won the scholarship lottery.

I walked around Union Sq. for hours today shopping for the perfect scarf. The first one I found is the one I ended up buying many hours later. I got a nice lunch and dinner. Now am in my pajamas relaxing and getting ready for the long day and night tomorrow.

Tuesday, October 22, 2013

Github Pages

http://jendiamond.github.io/

Wow, I can't believe that it is finally up! I had an incredible burst of focused energy and in my own house and at my desk even.

I was having a hard time getting the blog to publish and after a while I realized that the layout was not correct. I fixed that and it posted. Then I continued onward to styling and adding pages. I was so happy and proud of myself when it finally worked. There are so few of these moments amidst the struggle that I make sure I acknowledge them.

I am leaving for the Future Stack conference tomorrow morning so I am going to hit the hay.

Hooray!!! Hooray!!! Hooray!!!

Thursday, October 17, 2013

Model View Controller Explanation

Model The classes which are used to store and manipulate state, typically in a database of some kind.

View The user interface bits (in this case, HTML) necessary to render the model to the user.

Controller The brains of the application. The controller decides what the user's input was, how the model needs to change as a result of that input, and which resulting view should be used.


Let's use some of this to make a simple little text editor:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
filename = ARGV.first
script = $0

puts "We're going to erase #{filename}."
puts "If you don't want that, hit CTRL-C (^C)."
puts "If you do want that, hit RETURN."

print "? "
STDIN.gets

puts "Opening the file..."
target = File.open(filename, 'w')

puts "Truncating the file.  Goodbye!"
target.truncate(target.size)

puts "Now I'm going to ask you for three lines."

print "line 1: "; line1 = STDIN.gets.chomp()
print "line 2: "; line2 = STDIN.gets.chomp()
print "line 3: "; line3 = STDIN.gets.chomp()

puts "I'm going to write these to the file."

target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")

puts "And finally, we close it."
target.close()

Notes - Rails Tutorial Chapter 3.1

Sent PR to Bundler  hopefully it will get closed soon.
This fixes the issue: Warn if the same gem (same version) is added twice. bundler/bundler-features#22

To create the static views I am mainly in the app/controllers and the app/views directories

The config directory is where Rails collects files needed for the application configuration.

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
end

New in Rails 4
  • Previous versions of Rails used PUT in place of PATCH, and Rails 4.0 still supports this usage, but PATCH matches the intended HTTP usage better and is preferred for new applications. So GET, POST, PUT, DELETE is now GET, POST, PATCH, DELETE.

    Idempotence  is the property of certain operations in mathematics and computer science, that can be applied multiple times without changing the result beyond the initial application. It literally means "(the quality of having) the same power", from idem + potence (same + power).



Wednesday, October 16, 2013

Notes - Rails Tutorial Chapter 3.1 - Static Pages

I set the sample_app on GitHub and Herouku.

underscore method

Rails' ActiveSupport adds underscore to the String methods using the following code (This is NOT a String method in Ruby)

class String
  def underscore
    self.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
  end
end
underscore(camel_cased_word)
Makes an underscored, lowercase form from the expression in the string.

Changes ‘::’ to ‘/’ to convert namespaces to paths.

  'ActiveModel'. underscore    # => "active_model"
  'ActiveModel::Errors'.underscore    # => "active_model/errors"


As a rule of thumb you can think of it as the inverse of camelize, though there are cases where that does not hold:
'SSLError'
.underscore.camelize # => "SslError"

CREATE & DESTROY

$ rails generate controller FooBars baz quux
$ rails destroy controller FooBars baz quux
$ rails generate model Foo bar:string baz:integer
$ rails destroy model Foo
$ rake db:migrate
  We can undo a single migration step using
$ rake db:rollback
  To go all the way back to the beginning, we can use
$ rake db:migrate VERSION=0

Tuesday, October 15, 2013

has_many & belongs_to

The Microposts Resource parallel the User Resources.

config/routes.rb
DemoApp::Application.routes.draw do
  resources:microposts
  resources:users
  .
  .
  .
end

Active Record

Forming associations between different data models with has_many and belongs_to.

app/models/user.rb
class User < ActiveRecord::Base
  has_many :microposts
end
app/models/micropost.rb
class Micropost < ActiveRecord::Base
  belongs_to  :user
  validates, :content, length: { maximum: 140 }
end
micropost_user_association


Hierarchy


demo_controller_inheritance

Middleman Blog

I am working on setting up a new Middleman blog to replace the jekll one I set up and mangled. http://jendiamond.github.io/ I was having a problem with having multiple versions of Middleman installed so I deleted them and started over with the oldest version that I have installed for  working on the RGSOC Team blog and the Bundler website. I may install RVM finally so I can use the newest version. I need some assistance and guidance. Time to check in with Cynthia. She said she'd show me RVM.
http://rubylearning.com/blog/2010/12/20/how-do-i-keep-multiple-ruby-projects-separate/