Showing posts with label :: Ruby on Rails. Show all posts
Showing posts with label :: Ruby on Rails. Show all posts

Saturday, October 18, 2014

Friday, October 17, 2014

`autodetect': Could not find a JavaScript runtime on Ubuntu

When i starting the rails server, got the message " `autodetect': Could not find a JavaScript runtime "
googling and fix the issue with install a package:
sudo apt-get install nodejs

Thursday, October 16, 2014

Setup VPS for Ruby On Rails on Ubuntu 12.04 LTS

In this case, i'm using RVM for installing ROR

1. Update the Ubuntu

sudo apt-get update
sudo apt-get upgrade
after done, you need to restart the server for clean.
sudo shutdown -r now

2. Install MySQL

sudo apt-get install mysql-server mysql-client libapache2-mod-auth-mysql php5-mysql
Need, install the PHP for using phpmyadmin
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

3. Install dependencies

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion libpq-dev

4. Install Curl

sudo apt-get install curl

5. Install RVM

\curl -L https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm
After installed RVM, close your terminal and login back to use the "rvm" command: RVM has some dependencies to need install, run this command.
rvm requirements
and if any install some recommended dependencies

6. Install Ruby

rvm list known
Will display like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p547]
[ruby-]2.0.0-p481
[ruby-]2.0.0[-p576]
[ruby-]2.1.2
[ruby-]2.1[.3]
[ruby-]2.1-head
ruby-head
rvm install 2.1.2
rvm use 2.1.2 --default
check the version installed Ruby and Gem
ruby -v
gem -v

7. Install Rails

gem install rails

8. Install MySQL gem

Firstly, need install mysql dev
sudo apt-get install libmysqlclient-dev
gem install mysql2

9. Install ImageMagic

sudo apt-get install imagemagick

10. Install Javascript Runtime

sudo apt-get install nodejs

11. Install Phusion Passenger

gem install passenger
View script apache installation run this script:
passenger-install-apache2-module

Tuesday, March 11, 2014

ROR `autodetect': Could not find a JavaScript runtime on Centos 6

To fix this problem, please install some packages:
sudo yum install nodejs npm

Monday, March 10, 2014

Installing mysql gem on Centos 5

Firstly, install mysql dev:
sudo yum install mysql-devel
gem install mysql2

How to remove old installed rails

To removing old installed rails, just type:
sudo gem clean

How to cleanup the Ruby on Centos

To remove the current installed ruby, just type
sudo yum remove ruby
ruby -v

Saturday, March 8, 2014

rails Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Please check your MySQL first, may be MySQL engine not starting
So, start your MySQL and restart your rails application

Monday, March 3, 2014

How to installing Ruby on Rails on Centos 5

In this case i'm using RVM for installing ROR, now let's begin
Update your packages:
sudo yum update

1. Install RVM

sudo yum install curl
curl -L get.rvm.io | bash -s stable
After installed RVM, close your terminal and login back to use the "rvm" command:
RVM has some dependencies to need install, run this command.
rvm requirements
and install some recommended dependencies:
rvmsudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
rvm list known
Will display like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1.1
[ruby-]2.1-head
ruby-head
Install the Ruby
rvm install 2.1.1
rvm use 2.1.1 --default
check the version installed Ruby and Gem
ruby -v
gem -v

2. Install Rails

gem install rails

3. Install mysql gem

First, install the mysql dev:
sudo yum install mysql-devel
gem install mysql2

3. Install Phusion Passenger

gem install passenger
yum install curl-devel httpd-devel 
passenger-install-apache2-module
Put these lines to end of file in httpd.conf, edit the file at /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
   < IfModule mod_passenger.c >
     PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.37
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
   < /IfModule >
Adding new virtual host:
vi /etc/httpd/conf.d/your_vhost_name.conf
Add these line, set up your public app directory:
< VirtualHost *:80 >
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public    
      < Directory /somewhere/public >
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      < /Directory >
   < /VirtualHost >
Restart your apache
service httpd restart

Thursday, January 16, 2014

Library not loaded: libmysqlclient.18.dylib (LoadError) on Mac OS

When installed raisl 4.0.1, it's raise some error:
/opt/local/lib/ruby2.0/gems/2.0.0/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `require': dlopen(/opt/local/lib/ruby2.0/gems/2.0.0/extensions/x86_64-darwin-13/2.0.0/mysql2-0.3.14/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /opt/local/lib/ruby2.0/gems/2.0.0/extensions/x86_64-darwin-13/2.0.0/mysql2-0.3.14/mysql2/mysql2.bundle
  Reason: no suitable image found.  Did find
to fix this problem, type command below:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

Find location of installed system

Just simple command:
which ruby

Friday, January 3, 2014

Setup a Ubuntu VPS for Ruby on Rails Application

In this section, my VPS using Ubuntu Server OS

1. Connecting to your server


Login using SSH, as the root user
ssh root@100.100.100.100  #VPS IP Address
password: {your_password}

2. Create a new User

Add a new user to instead the root user
adduser your_username
password {enter_the_password_user}

3. Update the ubuntu

Make sure the Ubuntu is up date
sudo apat-get update

4. Install nano text editor

sudo apat-get install nano

5. Install RVM (Ruby Version Manager)

Firstly, we'll install the Curl
sudo apat-get install curl
Then, install the RVM
\curl -L https://get.rvm.io | bash -s stable
After installing is done, load the RVM. You may first need to exit out out your shell session (terminal) and start up a new one
source ~/.rvm/scripts/rvm

6. Install Ruby with RVM

First, RVM will check the dependencies to install ruby
rvm requirements
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
Now we can list all the availabel versions of Ruby that are available:
rvm list known
Will show list all Ruby version like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p484]
[ruby-]2.0.0-p195
[ruby-]2.0.0[-p353]
[ruby-]2.1.0
[ruby-]2.1.0-head
ruby-head
Select newest Ruby version and install with rvm:
rvm install 2.1.0
rvm --default use 2.1.0
Finally, you need to check installed the Ruby on your computer
ruby -v
gem -v

7. Install Rails

sudo gem install rails
Check rails version
raisl -v

Wednesday, January 1, 2014

Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile

Just simple way to fix that's problem
sudo apt-get install nodejs

Installing mysql2 gem on Ubuntu

sudo apt-get install libmysqlclient-dev
sudo gem install mysql2

Tuesday, December 31, 2013

Installing Rails 4 on Linux Ubuntu Server 12.04

Step 1: Install RVM


Before you install ruby, you need to install a few libraries by the components you are installing, enter the following command.
sudo apt-get install build-essential curl
\curl -L https://get.rvm.io | bash -s stable
after it installing is done, close your terminal and start new one to begin
check the 'rvm' command shell
rvm
in order to work, RVM has some of its own dependancies that need to be installed. To automatically install them:
rvm requirements

Step 2: Install Ruby


rvm install ruby
we need the system using the ruby current installed
rvm use ruby --default

Step 3: Install RubyGems


rvm rubygems current

Step 4: Install Rails


gem install rails

Saturday, October 19, 2013

ROR mysql2 "no implicit conversion of Fixnum into String"

When i access local app http://localhost:3000
getting error:

TypeError
no implicit conversion of Fixnum into String

database.yaml
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  database: app_development
  pool: 5
  username: root
  password: 123456
  socket: /tmp/mysql.sock

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  database: app_test
  pool: 5
  username: root
  password: 123456
  socket: /tmp/mysql.sock

production:
  adapter: mysql2
  encoding: utf8
  database: app_production
  pool: 5
  username: root
  password: 123456
  socket: /tmp/mysql.sock
To fix the error, just put double quote between password:
  pool: 5
  username: root
  password: "123456"
  socket: /tmp/mysql.sock
restart the server and reload the page.

Friday, October 18, 2013

Could not find 'railties' (>= 0) among 8 total gem(s) (Gem::LoadError) when installing Rails 4 on Mac Lion

Found this issue after installed Rails 4 and using RVM for manage the Ruby version

when i type :
rails -v
it's make rise some errors like the below:
.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (>= 0) among 8 total gem(s) (Gem::LoadError)
after googling about this issue, i have some references for solve the issue
possibility i was installing many times version ROR on mycomputer.
but i try the resolve my self, solved this.
here we go

1. Remove RVM

rvm implode

2. Check gem environment

gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.0
  - RUBY VERSION: 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-9
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/matt/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

3. Cleanup all old Ruby

rm -rf /Library/Ruby/Gems/1.8
rm -rf /System/Library/Frameworks/Ruby.framework/Versions/1.8
rm -rf /Users/your_username/.gem/ruby/1.8
rm -rf /usr/lib/ruby/gems/1.8

4. Reinstalling Rails 4

Follow this link to install Rails 4

Thursday, October 10, 2013

Installing Ruby on Rails 4 on Mac



For installing Rails 4, you must install or upgrade your Ruby version.
The Ruby must be higher then 1.9.3, read more
In this section i'm using Ruby 2.0







Step 1: Installing Ruby 2.0

I think you must install XCode firstly, after installed the XCode GCC was included,
it's make easy when installing Ruby.
To install Ruby here's have two ways:

  • Installing Ruby with Macports
  • Installing Ruby with RVM


Step 2: Installing Rails

sudo gem install rails

Rails 4: skip bundle when creating new app

Just simple code here:
rails new ggg --database=mysql --skip-bundle

How to remove RVM

It’s easy; just do the following:
rvm implode
or
rm -rf ~/.rvm