Friday 29 March 2013

gem MySQL installation



Gem:gem mysql install 

Well,we have the solution for you. Your Linux installation requires that the development libraries for MySQL to be installed in order to build the gem.  but sometimes   attempting to install the MySQL gem and you are receiving this error?

ERROR:
Fetching: mysql-2.9.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
-- .......................
       --.........................

Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.9.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

Here is the proper way for install this gem:

SOLUTION:

               sudo apt-get install libmysql-ruby
                      sudo apt-get install libmysqlclient-dev
                      sudo gem install mysql

Friday 22 March 2013

Ruby on Rails image upload




In this blog we see how to add image  in our rails application            
       
                     rails g uploader image( image replace any name)

  Gem file add following gem  
           GemFile

                                    gem "rmagick"
                                    gem "carrierwave"


in your model for example your user model


      model/user.rb
 
                  class user < ActiveRecord::Base
                     attr_accessible : :name, :user_image  
                     mount_uploader :user_image, ImageUploader
                  end

and

app/uploaders/image_uploader.rb


          class ImageUploader < CarrierWave::Uploader::Base
                        include CarrierWave::RMagick
                       storage :file             
                      def store_dir                      
                          "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"     
                       end           
                     version :thumb do                   
                          process :resize_to_limit => [200, 200]                   
                     end        
          end

Show.html.erb

        <%= image_tag painting.user_image_url(:thumb) if painting.image? %>

insert.htm.erb

              <%= f.file_field :user_image %>





Saturday 2 March 2013

Installing rmagick

Error

   Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/gowthaman/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /home/gowthaman/.rvm/gems/ruby-1.9.2-p320/bin:/home/gowthaman/.rvm/gems/ruby-1.9.2-p320@global/bin:/home/gowthaman/.rvm/rubies/ruby-1.9.2-p320/bin:/home/gowthaman/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/share/ruby-rvm/bin

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/gowthaman/.rvm/rubies/ruby-1.9.2-p320/bin/ruby


Gem files will remain installed in /home/gowthaman/.rvm/gems/ruby-1.9.2-p320/gems/rmagick-2.13.2 for inspection.
Results logged to /home/gowthaman/.rvm/gems/ruby-1.9.2-p320/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.


Solution:

         sudo apt-get install libmagickcore-dev libmagickwand-dev

git Installation

  Step 1 : sudo apt-get install git-core

  Step 2 : git config --global user.name "your user name"

  Step 3 : git config --global user.email "your email id"

  Step 4 : ssh-keygen -t rsa -C "Enter your mail id"

                  Generating public/private rsa key pair.

 Step 5 : Enter file in which to save the key (/home/gowthaman/.ssh/id_rsa): ssh-add (type this)
                        Note:It will suggest a default file name id_rsa.pub.
 Step 6 : Enter passphrase (empty for no passphrase):

 Step 7 : Enter same passphrase again:

                    Your identification has been saved in ssh-add.
                    Your public key has been saved in ssh-add.pub.
                    The key fingerprint is:80:15:61:4f:99:c9:e9:99:f4:d1:20:3e:8c:25:ad:27 your mail
                    The key's randomart image is:
                                   +--[ RSA 2048]----+
                                    |      ..+oo+o+   |
                                    |       + B*o+ .  |
                                    |      + .+=o .   |
                                    |     . .E =..    |
                                    |        So .     |
                                    |                 |
                                    |                 |
                                    +-----------------+

  Step 8 :Copy public key from ssh-add.pub. That key file contain somw key with your email.

            Key Like "ssh-rsa           AAAAB3NzaC1yc2EAAAADAQABAAABAQDLO1ARmpfDQl8CpdEPB9AVonxp9q05opFfi+Ix/Urn64Dyc2xhLyQMRVx8fd7XyA1mH4rAwVAyKhEWHJfo9QJsShDtS23q/Xq3QDQVwMrLDVMuFlTsKFdXL6zOe08W4D5kKJoj3fjKWyXdbwh9OHj1P1IdqxfwNTpnzRMCFHHLzIACIALBVyI2sdj7FPy2LktLmnXl3VXu9N6HKb3oWAXly+NDHmAaX6hYx81TjrOMNXwWqHpK5SYl5hX7k6KKbBlaJqeuPZ07tyK9/Q7FVbFiSue/3FN5LVllTST4M7f5ax+XBsKnRre+18mApB51Wy6mIzdq++/7X9LAXZZjSzl7"(Remove your email id and copy key).

Step9 : open your git account and edit profile add ssh keys.

Step 10:  Finally after add ssh key and verify   key fingerprint  in your mail.
  
                    git clone  help
            git clone  git@github.com:gowthaman14/jQuery-Validation-Engine.git

     ERROR

                Cloning into 'jQuery-Validation-Engine'...
                Permission denied (publickey).
               fatal: The remote end hung up unexpectedly

   Check that you are connecting to the correct server

    ssh -vT git@github.com

   you get
Permission denied (publickey).

   ssh -T gowthaman14@github.com(your git account name@github.com)

     you get
Permission denied (publickey).

Make sure you have a key and SSH is using it


To verify that you have a key generated and loaded into SSH, run ssh-add -l:

 ssh-add -l

print--like this  2048 a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)

If it does not print out anything, you need to add your key to SSH by running

-->ssh-add path/to/key.(ssh-add  ......setpath ssh-add.pub)