Blogs

View as a Table

Rails Server With Nginx and Puma Ubuntu 14.04 LTS


Part 1 - Setting up Ruby/Rails

Installing rbenv

We will use rbenv to be our Ruby version control. Let's update our app and then get the dependencies we need for our server.

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Once we have those dependencies, let's install rbenv.

``...


Read Blog Post


Setting Up PHP 7.1 macOS High Sierra


By default, macOS High Sierra comes with PHP 7.1 installed and Apache Apache/2.4.27 (Unix). But to get it to show up, we have to edit a few files.

There are also 3 different ways to do this, and after doing all three, I prefer the Homebrew method.

#1. Default Mac Method

First, let's start our Apache Server.

sudo apachectl start

Editing httpd.conf

Head to your apache2 httpd config path.

sudo vim /etc/apache2/httpd.conf

Then you will ne...


Read Blog Post


Rails Migrations


Create a Migration

Say we have a column in our users table that we are no longer needing, we can generate a migration and add any needed information afterwards.

rails g migration RemovePhoneNumberFromUsers phone_number:string

Rename a Column

rails g migration RenamePhoneNumberFromUsers

Polymorphic Associations

rails g migration AddCommentableToComments body:text commentable:references{polymorphic}

Foreign Keys

...


Read Blog Post


Installing Ruby/Rails on macOS High Sierra


In this guide, I will walk you through installing Brew, Ruby, and Rails on macOS High Sierra (currently the latest release). It is fairly straightforward on how to install it and run it.

Installing Xcode

With the newest release, Apple has made a ton of changes to the CL Tools and it practically forces you to install xcode, so that's what we'll do.

xcode-select --install

Installing Oh My Zsh

If you don't have a bash terminal and want one, I'd recommend usi...


Read Blog Post


Exporting CSV, PDF, XLS, XML, VCF in Rails


CSV Format

To save database information as a csv, we will need to require the rails csv library in the controller we are going to use it in. You also need to add the format in your view method you need it in.

# UsersController.rb
require 'csv'

def index
  # Your Code
  @users = User.all

  respond_to do |format|
    format.html
    format.csv
  end
end

Then in your index.csv.erb view file, you will need to add in the rows and columns you want to be displ...


Read Blog Post


Google ReCaptcha


Installing

This layout is formatted in slim, which is a rails templating engine. To install google's recaptcha, after registering your site, and getting your api keys, simply add these following lines in your code where you need it in your views.

.g-recaptcha data-sitekey="your-site-key" data-callback="myCallback"

script src="https://www.google.com/recaptcha/api.js"

javascri...

Read Blog Post


Installing and Using Redis on Ubuntu/Mac OS X


Mac OS X

Install Redis using homebrew.

brew install redis

After installing it, you will see some warning signs, just ignore those and move on with the rest of the tutorial.

To initiate Redis when your computer starts, run the following command.

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

Start Redis server via “launchctl”.

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Start Redis server ...


Read Blog Post


How To Do Family History Work


First Four Generations

If you haven't completed your first four generations, gather information about those ancestors, and add it to your family tree.

  1. Sign in to www.familysearch.org with your LDS Account, and then click ![alt text][ftree].
  2. If you are not already in landscape view, change the view to ![alt text][landscape].
  3. Look for green temple icons ![alt text][gtemple], record hints icons ![alt text][contact], and research suggestions icons ![alt text][research].
  4. C...

Read Blog Post


Cool Rails Commands


Fun Things

If you ever want to connect to your own server or someone else's over your ethernet, use the following command in your terminal to start your server:

rails s -b 0.0.0.0 -p 3000

Wanting to run two different rails servers at once on the same machine? Simply change the ports the are running on to have them run simultaneously.

rails s -p 3000 
rails s -p 4000

If you need to add any images to your rails app with carrierwave or in ...


Read Blog Post


Create Rake Tasks


Initial Setup

Creating rake tasks is an easy way to automate processes in rails. A sample rake task is found below. This specific tasks accepts two arguments, which are denoted using symbols in array format.

# lib/tasks/users.rake
require 'rake'

namespace :users do
  desc "Accepts a preset quantity of users to create along with an assigned role '[30, editor]'"
  task :add_users_with_role, [:qty, :role] => [:environment] do |t, args|
    args[:qty].to_i.times do |n|
...

Read Blog Post