Tuesday, September 23, 2008

Rails Console Tips & Tricks II

This is my second rails console tips & tricks. if you interested in reading previous tips and tricks read my first blog post regarding that matter.

This second part is about one command called "load" that is available in your Rails console. you can use this command to do many things as

1. to reload any file that was loaded when starting console and don't get reloaded when using "reload!" command such as files in your lib folder. to reload any file just write

load "#{RAILS_ROOT}/lib/{{file_name}}"


2. if you faced a problem such as "MySQL has gone away" just reload environment.rb once again as follows

load "#{RAILS_ROOT}/config/environment.rb"


3. also if you want to test a bunch of code in your console not just a single line of code, and want to be able to change part in it and rerun it once again then doing so in console is very time consuming and annoying so rather than doing so, you can write this code in a file and then

load "{{your-ruby-file}}"

Monday, September 8, 2008

Ruby Make Problem

Still in my early days using Linux and trying to compile ruby 1.9 on my machine in order to move my working environment to Linux

I downloaded ruby 1.9 source from ftp.ruby-lang.org and as stated in readMe file, i ran

./configure --prefix={{any-desired-path}}

successfully then ran

make

it took some time then i was faced with that error

executable host ruby is required. use --with-baseruby option.

What is that error? and what ruby?? i am compiling ruby how come i need it.


Anyway, i began searching for an explanation. i reached to a comment in one of the forums stating that this error can occur in these two cases

1. ruby isn't in the default path
2. ruby isn't installed

More investigation showed that i should have any previous version of ruby installed in order to use it with that make file as follows

./configure --prefix={{any-desired-path}} --with_baseruby={{full-path-to-ruby-executable}}

then run make command once again. And it worked finally

What a nice recursive world, "ruby is needed to compile ruby"

Thursday, September 4, 2008

configure: error: C compiler cannot create executables

In my first start to use ubuntu, i wanted to compile ruby on my machine

i downloaded ruby source and executed configure file to generate make file

./configure

i got this error

C compiler cannot create executables

although i have gcc latest version installed



after investigating this error i found that the solution was

sudo apt-get install build-essential


after doing so, everything worked fine