Closures are inner functions that have access to the outer function’s variables, also known as a scope chain. Included in a closure’s scope chain are the closure’s own variables, the outer function’s variables, and any global variables. The inner function also has access to the outer functions parameters.
3 comments
33 comments
Creating a Simple Search in Rails 4
If you have a blog and you want the user to be able to search your posts, you will need to add methods to both your posts controller and post model, and create a corresponding search form.
1 comment
Adding a Static Page to a Rails Application
Adding a new static page to an existing Rails application can be accomplished in a few easy steps: (1) create a static controller, (2) generate static views, and (3) create corresponding routes.
31 comments
Rails: Generate Model vs. Resource vs. Scaffold
If you’re just learning Ruby on Rails, you may be confused as to when to generate individual models, resources or scaffolding, and what files are created by each command.
6 comments
Rails Tutorial: Getting Started with Ruby on Rails
Rails is a web application framework written in Ruby, also known as an MVC, or Model View Controller. Rails has two major philosophies: (1) DRY (“Don’t Repeat Yourself”) and (2) Convention Over Configuration, meaning Rails has a right and wrong way of doing things, and if you follow the Rails way, you shouldn’t have to… Read More
1 comment
The Importance of Web Application Security
Last week, I deployed my first web applications, a big moment in any developer’s life. One app, a guestbook for my friend’s wedding, was written in Ruby, dependent on the Sinatra gem and deployed through Heroku. It consisted of a simple form where friends and family could leave messages for the happy couple. I excitedly… Read More
0 comments
A Beginner’s Guide To RSpec
RSpec is a behavior-driven testing tool for the Ruby language. RSpec is used in test driven development (“TDD”), where the developer writes the test based on what s/he hopes the program will accomplish, and then creates the program to accomplish the goals of the test. While this would seem to create additional work for the… Read More
11 comments
Nested Arrays, Hashes & Loops in Ruby
Arrays and hashes are common data types used to store information. The main difference between an array and a hash is the manner in which data is stored. Arrays, represented by square brackets, contain elements which are indexed beginning at 0. So if an array contained three elements, the indexes for those elements would be… Read More
0 comments
Git Branching
Branches are copies of a repository where you can create changes without modifying the parent or master file. Branching is useful for experimental changes, fixing bugs and changes you aren’t sure you want to commit yet. Branching is especially useful when working on a project with multiple developers.
0 comments
SQL Cheat Sheet
SQL is used to create databases in which to store information. SQL serves the same essential purpose as an Excel spreadsheet.