class PostsController < ApplicationController | |
caches_page :index, :show | |
def index | |
#if nothing happens that should affect the cache leave it alone | |
end | |
def edit | |
#in any class that has potentional to change cache |
def is_fibonacci?(i) | |
require "bigdecimal" | |
require "bigdecimal/math" | |
include BigMath | |
plusfour = 5 * i**2 + 4 | |
minusfour = 5 * i**2 - 4 | |
#second argument is number of decimels for all big num arguments | |
plusfour = BigDecimal.new(plusfour, 5) |
class BoggleBoard | |
# because we wanted to | |
def initialize (board_size = 4) | |
@board_size = board_size | |
shake! | |
end | |
def shake! | |
possible_dice = [ | |
"AAEEGN", |
class Vehicle | |
@wheels = 4 | |
def initialize args | |
@color = args[:color] | |
end | |
def drive | |
@status = :driving | |
end |
<!doctype html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css"> | |
<link rel="stylesheet" href="main.css"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800"> | |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900"> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css"> | |
</head> |
Testing is helpful for ensuring that your code runs (driver code). This is to make sure that current features work, old features still work, and future work will be easily tested. By default, every Rails application has three environments: development, test, and production.
Rails offers three kinds of testing:
- Unit tests: In the context of Rails, unit tests are meant primarily to cover the domain logic in your models, which include things like validations, calculations, search methods, and any other interesting functionality that your models implement.
- Functional tests: These provide a way to verify that the actions for a single controller are working as expected, and allow you to do things such as post data to a specific action and verify the correct response is returned
- Integration tests: Any given session with a Rails application will span across several models and controllers. Integration tests provide a way to test those kinds of interactions. Essentia
This tutorial is going to help you start off on the right foot by teaching you a few things that aren't Ruby. These things are, however, important to undestand for your future in the industry. If you are running MacOS or any flavor of Linux you are going to be very comfortable fitting into a Ruby workflow. Windows users will find that since so much of Ruby workflow is based on shell tools (and Windows has no real linux shell support) life is going to be a bit more interesting.
Furthermore all staff (and and an overwhelming majority of Rubyists) use OSX. If you are on windows either get dirty and start solving these problems for yourself or check out Rails Installer
OSX Users you could of course also use Rails Installer, however, as is true or so many things pre-packaged for you: this quick boost will be a net drag in the long-term. We would prefer that you build your environment yourself s
# 1. Require the gem sqlite3. You must `gem install sqlite3` if you get an error | |
# stating `cannot load such file -- sqlite3` | |
# This will add the gem to your local gemset | |
require 'firebase' | |
require 'faker' | |
# 2. Sign up for a firebase account and set the uri here | |
base_uri="https://luminous-fire-2162.firebaseio.com/" | |
# 3. Set up a connection to the database you have created |