tag:blogger.com,1999:blog-82543851192002552722023-11-15T07:43:31.376-08:00rails blogckgaganhttp://www.blogger.com/profile/05500826842321617785noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8254385119200255272.post-23341889517341116632011-08-22T21:00:00.000-07:002011-09-02T19:13:32.720-07:00ActiveRecord callback execution sequence..<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: center;"><pre class="code"> Given below are the sequence of executions of</pre><pre class="code">ActiveRecord callbacks.</pre><pre class="code">Its handy when you have to execute particular piece of code at</pre><pre class="code">particular time of record creation.</pre><pre class="code"> </pre><pre class="code"><b>For before_persisting callback </b></pre><pre class="code"> before_persisting
persist
after_persisting
[save record if record.changed?]
</pre><pre class="code"><b>For befor_validation callback</b>
before_validation
before_validation_on_create
before_validation_on_update</pre><pre class="code">validate
after_validation_on_update
after_validation_on_create
after_validation
[save record if record.changed?]</pre><pre class="code"> </pre><pre class="code"><b>For before_create and before_update callback</b></pre><pre class="code">before_save</pre><pre class="code">before_create</pre><pre class="code">before_update</pre><pre class="code">saves the record</pre><pre class="code">after_update</pre><pre class="code">after_create</pre><pre class="code">after_save
[save record if record.changed?]
</pre><pre class="code"><b>For before_destory callback</b>
before_destroy
[save record if record.changed?]
destroy
after_destroy</pre></div></div>ckgaganhttp://www.blogger.com/profile/05500826842321617785noreply@blogger.com0tag:blogger.com,1999:blog-8254385119200255272.post-57468724298834081202011-08-20T18:25:00.000-07:002011-09-02T19:14:45.064-07:00<div dir="ltr" style="text-align: left;" trbidi="on"><h1 class="entry-title">error: no such file to load — readline </h1><h1 class="entry-title"><span style="font-size: small;"><span style="font-weight: normal;">The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. (…) The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous command.</span></span></h1><h1 class="entry-title"><span style="font-size: small;"><span style="font-weight: normal;">For more info about read line visit <a href="http://bogojoker.com/readline/">http://bogojoker.com/readline/ </a></span></span></h1><div class="entry-content">When I started rails console: I got an error saying:<br />
<b>no such file to load — readline (LoadError)</b>. At that time i was on Ubuntu 10.04 system with rvm, rails3, ruby 1.9.2-p290.<br />
I tracked down redline in my ruby source ~/.rvm/src/ruby-1.9.2-p290/ext/readline and ran:<br />
<blockquote><pre><b>ruby extconf.rb</b></pre></blockquote>(Note: here ruby-1.9.2-p290 is the default ruby in rvm. Replace with your ruby version if you have to.)<br />
This let me know I was missing these two packages:<br />
<blockquote><b>l</b><b>ibncurses5-dev and libreadline5-dev</b></blockquote>Install these packages with this command <b><br />
</b><br />
<blockquote><pre><b>sudo apt-get install libncurses5-dev libreadline5-dev</b></pre></blockquote>Then run the command from before:<br />
<blockquote><pre><b>ruby extconf.rb</b></pre></blockquote><pre>Note :</pre><pre>You should be in the ~/.rvm/src/ruby-1.9.2-p290/ext/readline</pre><pre>directory while entering this command.</pre>I think you should get all passing.<br />
<blockquote><pre><b>make
make install</b></pre></blockquote>Hurray now <b>rails c</b> works.</div></div>ckgaganhttp://www.blogger.com/profile/05500826842321617785noreply@blogger.com0tag:blogger.com,1999:blog-8254385119200255272.post-24296544366379525292011-08-19T08:55:00.000-07:002011-10-17T16:53:57.812-07:00Install Rails in Ubuntu with RVM<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-size: small;">Before installing rvm first of all you need to install a latest version of git in your system.</span><br />
<span style="font-size: small;">Run this command in the terminal</span><br />
<blockquote><div style="text-align: left;"><span style="font-size: small;"><b><span class="st">sudo aptitude build-dep git-core</span></b></span></div></blockquote><span style="font-size: small;">Then run the command </span><br />
<blockquote><pre class="code"><span style="font-size: small;"><b>bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)</b></span></pre></blockquote><span style="font-size: small;">to install rvm in your machine.</span><br />
<span style="font-size: small;">Now run the command</span><br />
<blockquote><pre class="code"><span style="font-size: small;"><b>echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" </b></span></pre></blockquote><blockquote><pre class="code"><span style="font-size: small;"><b># Load RVM function' >> ~/.bash_profile</b></span></pre></blockquote><h3 style="font-weight: normal;"><span style="font-size: small;">To load RVM into your shell sessions as a function.</span></h3><h3 style="font-weight: normal;"><span style="font-size: small;">Now reload the bash with</span></h3><blockquote><pre class="code"><span style="font-size: small;"><b>source .bash_profile</b></span></pre></blockquote><span style="font-size: small;">If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output <i>'rvm is a function'</i> as shown below. </span><br />
<blockquote><pre class="code"><span style="font-size: small;"><b>type rvm | head -1</b></span></pre></blockquote><h3 style="font-weight: normal;"></h3><span style="font-size: small;"> Now install ruby with rvm with this comand</span><br />
<blockquote><pre class="code"><span style="font-size: small;"><b>rvm install 1.9.2-p290</b></span></pre></blockquote><span style="font-size: small;">where 1.9.2-p290 is ruby version that we want to install.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;">now make ruby 1.9.2 your default ruby for the system with this command</span><br />
<blockquote><pre class="code"><span style="font-size: small;"><b>rvm use 1.9.2 --default</b></span></pre></blockquote><span style="font-size: small;">Now install rails with </span><br />
<blockquote><span style="font-size: small;"><b>gem install rails --no-ri --no-rdoc</b></span></blockquote>if you get the following error<br />
<br />
<b>ERROR: Loading command: install (LoadError)<br />
no such file to load -- zlib<br />
ERROR: While executing gem ... (NameError)<br />
uninitialized constant Gem::Commands::InstallCommand</b><br />
then you must install zlib package. Use the following commands if above error shows up<br />
<br />
<br />
<pre class="code"><b>$ rvm pkg install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-zlib-dir=$rvm_path/usr</b></pre><br />
<br />
<span style="font-size: small;">here --no-ri --no-rdoc will not install ri and rdoc documentation.</span><br />
<span style="font-size: small;"><br />
</span><br />
<span style="font-size: small;"><br />
</span><br />
<br />
<br />
<blockquote><pre class="code"></pre></blockquote><br />
</div>ckgaganhttp://www.blogger.com/profile/05500826842321617785noreply@blogger.com0