Skip to main content

Install Ruby on Rails on MAC



Hello, I am quite familliar with Apache's friend products like XAMPP, LAMPP... And this is the first time I try Ruby on Rails(RoR).
I'm quite stuck on installing it.

As a normal PHP guy, I first try install Rails, following this tutorial:
http://installrails.com/

And the next thing I want to learn about is how RoR works with MySQL, PhpMyadmin. So I tried to make it connect to XAMPP's MySQL but it did not work at all. I found out that, using mySQL in XAMPP package is not a common method, what I should do is to install MySQL as a single service onto my MAC. So I did following:

1. Install MYSQL with HomeBrew
Did you install HomeBrew, if not, please follow: https://coolestguidesontheplanet.com/installing-homebrew-on-os-x-el-capitan-10-11-package-manager-for-unix-apps/

Next, type this command to install MySQL to your machine:
$ brew install mysql

This will install mysql to your computer, if the installation is success, you could try start using mySQL with this command:
$ brew services start mysql

>>>>Remember, this will not work if you are running XAMPP's MySQL  service because it is using the same port. You need to stop XAMPP's MySQL first

2. Install Ruby Mysql adapter
You need to tell Ruby to install mysql adapter, normally people using 1 of  this 2 adapters:
$ gem install mysql
$ gem install mysql2

3. OK, now you can run your Rails app with MySQL
When coming here, someone might want to manage your prev-intalled MySQL with PhpMyAdmin, poor you, there is not so easy to do that because you will need to install PhpMyadmin, Apache, Php by yourself, single component separately. This will not be easy.

But you do not need to do that, because Ruby does not care about PhpMyAdmin, Apache or even PHP, it can run on it own sake. What you really need is a tool to manage your MySQL database, so, just find and download MySQL Workbench, a great tool, and much easy to use.

OK, remember that learning MySQL Workbench is easy too, just create schema(like create Database), and create table...

But in Linux, or another server, you will need to install MySQL and PHPMyAdmin by your self. So, I will write it in another writing, you might want to follow this on DigitalOcean: Install LAMPP and install PHPMyadmin

4. Config database for rails app
You will need to config file database.yml
default: &default
   adapter: mysql2
   encoding: utf8
   pool: 5
   username: root


   password:

No need for socket in this case, but you can find your socket location at mySQLWorkbench 

5. Run server
rails server


Comments

  1. It is nice blog Thank you porovide important information and i am searching for same information to save my time Ruby on Rails Online Course

    ReplyDelete

Post a Comment

Popular posts from this blog

Setup splunk for virtual machine using Vagrant and Ansible

Splunk is a great tool for collecting and indexing data in any kind(log files, changes, tickets, scripts…) from any sources (sensors, networks, databases, smartphones,..( Then creating index for data which then support us to analyse data or search data in the way we like it. We want to try installing Splunk on Virtual environment in order to test, try, study… And with Vagrant&Ansible we can easily save our virtual machine configuration for next time use(in case my virtual machine was broken). There is already Splunkbox by Phips on githubs for simply installing:  https://github.com/phips/splunkbox 1.Download and install Virtual Box (You need a Virtual machine provider for Vagrant(Virtualbox is prefered)) https://www.virtualbox.org/wiki/Downloads 2. Download and install Vagrant   http://www.vagrantup.com/downloads 3. Download and install Ansible   http://docs.ansible.com/intro_installation.html   For MAC:  https://devopsu.com/guides/ansible-mac-osx.html

iOS 13 presentViewController has updated transition way

Very surprised that my weather widget app is not updated it content automatically after a view has appeared. First, I called self presentViewController to present a view, after closing that view, I hope that my below view will call  -( void )viewWillAppear:( BOOL )animated{ but nothing happens. I started figuring out that on iOS 13, the view which is presented is displaying like a floating window, not fullscreen, like below. This is new in iOS 13. Quite cool, you can swipe the screen down, without pressing a close button. in order to get the below view called, you need to use Delegate BIG CHANGE~