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.
``...
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.
First, let's start our Apache Server.
sudo apachectl start
Head to your apache2 httpd config path.
sudo vim /etc/apache2/httpd.conf
Then you will ne...
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
rails g migration RenamePhoneNumberFromUsers
rails g migration AddCommentableToComments body:text commentable:references{polymorphic}
...
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.
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
If you don't have a bash terminal and want one, I'd recommend usi...
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...
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...
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 ...
If you haven't completed your first four generations, gather information about those ancestors, and add it to your family tree.
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 ...
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|
...