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.
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.
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.
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.
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
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
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
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
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.
SQL is used to create databases in which to store information. SQL serves the same essential purpose as an Excel spreadsheet.