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

How to remove all GEM

Removing all "gem"
List all gems
gem list
Remove all gems
sudo gem uninstall -Iax

How to install Ruby 2.0 using Port on Mac (Macports)

Step 1: Install Macports

Firstly, let's install the Macport

Step 2: Install Ruby 2.0

port selfupdate -v
port list | grep ruby
sudo port install ruby20

Step 3: Make symbolic link

sudo port select --set ruby ruby20
or
cd /opt/local/bin
sudo ln -s ruby20 ruby

How to install Ruby 2.0 on Mac using RVM

Step 1: Installing RVM


Installing the stable release version:
\curl -L https://get.rvm.io | bash -s stable
For more options follow rvm guide

Step 2: Restart Terminal


To use the "rvm" command, let's restart the Terminal (cmd + q)
ensure the "rvm" command work, type that code on your Terminal
rvm

Step 3: Download Ruby 2.0


rvm list known

Step 4: Installing Ruby 2.0


rvm install 2.0.0

Step 5: Make default Ruby 2.0


rvm use 2.0.0 --default 

Friday, October 4, 2013

Where is hosting svn repositories ?

Hi All,
Here's the list of where you can hosting your project with Subversion (SVN)
and many more.. you can googling :)

How to auto load file class in PHP

Here's the sample how to load class in the file of PHP
here we go! Let's put two files in the html(/var/www/html) directory on your computer.
First file contain of Class code:
# sample.php

< ?php

class Sample
{
    // property declaration
    public $var = 'hello world';

    // method declaration
    public function display() {
        echo $this->var;
    }
}

? >

Second file:
# load.php

< ?php

function __autoload($class_name) {
    include strtolower($class_name) . '.php';
}

$obj  = new Sample();

echo $obj->display();

? >

Next step is access load.php file from localhost:
http://localhost/load.php for more visit this page