<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Developer Code book &#187; Ruby on Rails</title> <atom:link href="http://wordpressapi.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" /><link>http://wordpressapi.com</link> <description>Wordpressapi.com is focused on Wordpress API, wordpress news, wordpress themes, wordpress plugins, wordpress tips, wordpress tutorials, wordpress design wordpress templates, wordpress breaking news and web-development. We deliver useful information about wordpress,  wordpress latest trends and wordpress techniques, wordpress useful ideas, wordpress innovative approaches and wordpress tools. Social Media news blog covering cool new websites and social networks: Facebook, Google, Twitter, MySpace and YouTube.  The latest web technology news, via RSS daily.</description> <lastBuildDate>Thu, 09 Sep 2010 10:36:02 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Active Model in Rails 3.0</title><link>http://wordpressapi.com/2010/07/04/active-model-rails-3-0/</link> <comments>http://wordpressapi.com/2010/07/04/active-model-rails-3-0/#comments</comments> <pubDate>Sun, 04 Jul 2010 07:25:09 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[tutorials]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ROR]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=4043</guid> <description><![CDATA[The technique we used was quite a hack as this is something that ActiveRecord wasn’t designed to do but now in Rails 3.0 we have a new feature called ActiveModel which makes doing something like this a lot easier. Before we get into the details of ActiveModel we’ll first describe the part of the application.....]]></description> <content:encoded><![CDATA[<p>The technique we used was quite a hack as this is something that  ActiveRecord wasn’t designed to do but now in Rails 3.0 we have a new  feature called ActiveModel which makes doing something like this a lot  easier.</p><p>Before we get into the details of ActiveModel we’ll first describe  the part of the application that we’re going to modify to use it.</p><p><a
href="http://wordpressapi.com/files/active-record.png"><img
class="alignnone size-full wp-image-4044" title="active-record" src="http://wordpressapi.com/files/active-record.png" alt="" width="801" height="465" /></a></p><p>The screenshot above shows a contact form that has been created using  Rails’ scaffolding. The application has a model called <code>Message</code> that is currently backed by ActiveRecord which means that we’re  managing messages through the database. We’re going to change the way  this form works so that it just sends emails and doesn’t store messages  in a database table.</p><p>When you’re thinking of doing something like this it’s always a good  idea to first consider your requirements and make sure that you really  don’t want to store the data from the form in a database as there are  often good side-effects to doing this. A database can act as a backup  and also makes it easier to move the message-sending into a queue in a  background process. For the purposes of this example, however, we don’t  want any of that  functionality so we’re free to go ahead and make our  model tableless.</p><p>The code for the Message class looks like this:</p><p>File name: /app/models/message.rb</p><pre class="brush: ruby;">

class Message &lt; ActiveRecord::Base
 validates_presence_of :name
 validates_format_of :email, :with =&gt; /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
 validates_length_of :content, :maximum =&gt; 500
end
</pre><p><code>Message</code> inherits from <code>ActiveRecord::Base</code> as  you would expect a model class to, but as we don’t want this model to  have a database back-end we’re going to remove that inheritance. As soon  as we do this, though, our form will no longer work as the validators  are provided by ActiveRecord. Fortunately, we can restore this  functionality by using ActiveModel.</p><p>If we take a look at the <a
href="http://github.com/rails/rails/">Rails  3 source code</a> we’ll see the that there are <code>activerecord</code> and <code>activemodel</code> directories. The core Rails team has taken  everything from ActiveRecord that wasn’t specific to the database  backend and moved it out into ActiveModel. ActiveRecord still relies  heavily on ActiveModel for the functionality that isn’t specific to the  database and as ActiveModel is full-featured and thoroughly tested it’s  great for use outside ActiveRecord.</p><p>It we take a look in the directory that contains the <a
href="http://github.com/rails/rails/tree/master/activemodel/lib/active_model/">code  for ActiveModel</a> we can see the functionality that it provides.</p><p>We can see from the list above that ActiveModel includes code to  handle callbacks, dirty tracking, serialization and validation, among  other things. The last of these is exactly what we’re looking for.</p><p>The <a
href="http://github.com/rails/rails/blob/master/activemodel/lib/active_model/validations.rb">code  for validations</a> has the following comment near the top and we can  see from it that it’s fairly easy to add validations to a model. All we  need to do is include the <code>Validations</code> module and provide  getter methods for the attributes that we’re calling validators on.</p><p>Now that we know this we can apply it to our Message model.</p><p>File name: /app/models/message.rb</p><pre class="brush: ruby;">

class Message
 include ActiveModel::Validations

 attr_accessor :name, :email, :content

 validates_presence_of :name
 validates_format_of :email, :with =&gt; /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
 validates_length_of :content, :maximum =&gt; 500
end
</pre><p><code>Message</code> inherits from <code>ActiveRecord::Base</code> as  you would expect a model class to, but as we don’t want this model to  have a database back-end we’re going to remove that inheritance. As soon  as we do this, though, our form will no longer work as the validators  are provided by ActiveRecord. Fortunately, we can restore this  functionality by using ActiveModel.</p><p>If we take a look at the <a
href="http://github.com/rails/rails/">Rails  3 source code</a> we’ll see the that there are <code>activerecord</code> and <code>activemodel</code> directories. The core Rails team has taken  everything from ActiveRecord that wasn’t specific to the database  backend and moved it out into ActiveModel. ActiveRecord still relies  heavily on ActiveModel for the functionality that isn’t specific to the  database and as ActiveModel is full-featured and thoroughly tested it’s  great for use outside ActiveRecord.</p><p>It we take a look in the directory that contains the <a
href="http://github.com/rails/rails/tree/master/activemodel/lib/active_model/">code  for ActiveModel</a> we can see the functionality that it provides.</p><p>We can see from the list above that ActiveModel includes code to  handle callbacks, dirty tracking, serialization and validation, among  other things. The last of these is exactly what we’re looking for.</p><p>The <a
href="http://github.com/rails/rails/blob/master/activemodel/lib/active_model/validations.rb">code  for validations</a> has the following comment near the top and we can  see from it that it’s fairly easy to add validations to a model. All we  need to do is include the <code>Validations</code> module and provide  getter methods for the attributes that we’re calling validators on.</p><p>Now that we know this we can apply it to our Message model.</p><p>File name: /app/models/message.rb</p><pre class="brush: ruby;">

class Message
 include ActiveModel::Validations

 attr_accessor :name, :email, :content

 validates_presence_of :name
 validates_format_of :email, :with =&gt; /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
 validates_length_of :content, :maximum =&gt; 500
end
</pre><p>This isn’t enough to get our model to behave as the controller expects  it to, though. There are two problems in the <code>create</code> method.  Firstly the call to <code>Message.new</code> won’t work as our <code>Message</code> model no longer has an initializer that takes a hash of attributes as  an argument. Secondly, <code>save</code> won’t work as we don’t have a  database backend to save the new message to.</p><p>Filename : /apps/controllers/messages_controller.rb</p><pre class="brush: ruby;">

class MessagesController &lt; ApplicationController
 def new
 @message = Message.new
 end

def create
 @message = Message.new(params[:message])
 if @message.save
 # TODO send message here
 flash[:notice] = &quot;Message sent! Thank you for contacting us.&quot;
 redirect_to root_url
 else
 render :action =&gt; 'new'
 end
 end
end
</pre><p>We’ll fix the second of these problems first. While we can’t save a  message we can check that it is valid, so we’ll replace <code>@message.save</code> with <code>@message.valid?</code>.</p><p>File name :/app/controllers/messages_controllers.rb</p><pre class="brush: ruby;">

def create
 @message = Message.new(params[:message])
 if @message.valid?
 # TODO send message here
 flash[:notice] = &quot;Message sent! Thank you for contacting us.&quot;
 redirect_to root_url
 else
 render :action =&gt; 'new'
 end
end
</pre><p>We can solve the first problem by writing an <code>initialize</code> method in the <code>Message</code> model that takes a hash as a  parameter. This method will loop through each item in the hash and  assign the value to the appropriate attribute for the message using the <code>send</code> method.</p><p>File name: /app/models/message.rb</p><pre class="brush: ruby;">

class Message
 include ActiveModel::Validations

attr_accessor :name, :email, :content
 validates_presence_of :name
 validates_format_of :email, :with =&gt; /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
 validates_length_of :content, :maximum =&gt; 500
 def initialize(attributes = {})
 attributes.each do |name, value|
 send(&quot;#{name}=&quot;, value)
 end
 end
end
</pre><p>If we reload the form now we’ll see that we’re not quite there yet,  however.</p><p>This time the error is caused by a missing <code>to_key</code> method  in the <code>Message</code> model. The error is thrown by the <code>form_for</code> method so it seems that Rails itself is expecting our model to have  functionality that it doesn’t yet support. Let’s add that functionality  now.</p><p>Rather than guessing everything that Rails expects the model to have  there’s a nice <a
href="http://github.com/rails/rails/blob/master/activemodel/lib/active_model/lint.rb">lint  test</a> included with ActiveModel that allows us to check whether our  custom model behaves as Rails expects it to. If we include the <code>ActiveModel::Lint::Tests</code> module in a tests for the model it will check that the model has all of  the required functionality.</p><p>The source code for the <code>Lint::Tests</code> module shows the  methods that the model needs to respond to in order for it to work as it  should, including <code>to_key</code>. We can make our model work by  including a couple of ActiveRecord modules. The first of these is <a
href="http://github.com/rails/rails/blob/master/activemodel/lib/active_model/conversion.rb"><code>Conversion</code></a>,  which provides that to_key method and several others. The other module  is the <a
href="http://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb"><code>Naming</code></a> module, but in this case we extend it in our class rather than  including it as it includes some class methods.</p><p>As well as including the <code>Conversion</code> module we need to  define a <code>persisted?</code> method in our model, which needs to  return <code>false</code> as our model isn’t persisted to a database.  With these changes in place our <code>Message</code> model now looks  like this:</p><p>File name: /app/models/message.rb</p><pre class="brush: ruby;">

class Message
 include ActiveModel::Validations
 include ActiveModel::Conversion
 extend ActiveModel::Naming
 attr_accessor :name, :email, :content
 validates_presence_of :name
 validates_format_of :email, :with =&gt; /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
 validates_length_of :content, :maximum =&gt; 500
 def initialize(attributes = {})
 attributes.each do |name, value|
 send(&quot;#{name}=&quot;, value)
 end
 end
 def persisted?
 false
 end
end
</pre><p>If we reload the form now it will work again which means that the <code>Message</code> model now satisfies all of the requirements that Rails 3 relies on for a  model. If we try to submit the form we’ll see that the validators are  working, too.</p><p><a
href="http://wordpressapi.com/files/active-record1.png"><img
class="alignnone size-full wp-image-4045" title="active-record1" src="http://wordpressapi.com/files/active-record1.png" alt="" width="800" height="631" /></a></p><p>We’ve only covered a little of what ActiveModel provides in this episode  but this should have been enough to whet your appetite and give you a  reason to look more deeply into its source code to see what it can do.  The code is well documented and structured so if you see something you  might find useful then there should be enough information in the  comments for that file to get you started using it.</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/07/04/active-model-rails-3-0/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Ruby 1.8.7-p299 version is released</title><link>http://wordpressapi.com/2010/06/25/ruby-1-8-7-p299-version-released/</link> <comments>http://wordpressapi.com/2010/06/25/ruby-1-8-7-p299-version-released/#comments</comments> <pubDate>Fri, 25 Jun 2010 05:50:38 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[news]]></category> <category><![CDATA[technology]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=3591</guid> <description><![CDATA[Today Ruby released the new version of ruby &#8211; Ruby 1.8.7-p299. It is avaible for download from following URLs: * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.gz * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.bz2 * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.zip Hello all. It&#8217;s time for a new release of 1.8.7. This time Ruby fixed various bugs, including the Unicode inspection bug that annoyed you a lot. For a complete list.....]]></description> <content:encoded><![CDATA[<p><a
href="http://wordpressapi.com/files/Ruby-1.8.7-p299-released._1277442860108.png"><img
class="alignnone size-full wp-image-3592" title="Ruby 1.8.7-p299 released._1277442860108" src="http://wordpressapi.com/files/Ruby-1.8.7-p299-released._1277442860108.png" alt="" width="316" height="126" /></a></p><p>Today Ruby released the new version of ruby &#8211; Ruby 1.8.7-p299. It is avaible for download from following URLs:<br
/> * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.gz<br
/> * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.bz2<br
/> * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.zip</p><p>Hello all. It&#8217;s time for a new release of 1.8.7.</p><p>This time Ruby fixed various bugs, including the Unicode inspection bug that annoyed you a lot. For a complete list of what has been fixed, please take a look at the ChangeLog.</p><p>* ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.gz<br
/> * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.tar.bz2<br
/> * ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p299.zip</p><p>Checksums:</p><p>MD5(ruby-1.8.7-p299.tar.gz)= 43533980ee0ea57381040d4135cf9677<br
/> SHA256(ruby-1.8.7-p299.tar.gz)= 32c99c8e3d0a0190942055b8239f1573677a02de2645d81539617011f3a5427b<br
/> SIZE(ruby-1.8.7-p299.tar.gz)= 4867600</p><p>MD5(ruby-1.8.7-p299.tar.bz2)= 244439a87d75ab24170a9c2b451ce351<br
/> SHA256(ruby-1.8.7-p299.tar.bz2)= 3d8a1e4204f1fb69c9e9ffd637c7f7661a062fc2246c559f25fda5312cfd65d8<br
/> SIZE(ruby-1.8.7-p299.tar.bz2)= 4183359</p><p>MD5(ruby-1.8.7-p299.zip)= b548dbdfc036979bdcb5e0962c87c9eb<br
/> SHA256(ruby-1.8.7-p299.zip)= 30e3ed4ce977a770223f34997ea0d025c180c4664a0bd0d35ef09e48d5c89860<br
/> SIZE(ruby-1.8.7-p299.zip)= 5965156</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/06/25/ruby-1-8-7-p299-version-released/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to deploy rails website with passenger -rails deployment with passenger</title><link>http://wordpressapi.com/2010/06/23/deploy-rails-website-passenger-rails-deployment-passenger/</link> <comments>http://wordpressapi.com/2010/06/23/deploy-rails-website-passenger-rails-deployment-passenger/#comments</comments> <pubDate>Wed, 23 Jun 2010 10:06:35 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[passenger]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[rails deployment]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=3530</guid> <description><![CDATA[While working with PHP, I realized that deployment of a PHP application is far more easier as compared to deployment of a Ruby on Rails application. So I was wondering if there could be a way to deploy a Ruby on Rails application in a similar fashion, as easy as you check out the Rails.....]]></description> <content:encoded><![CDATA[<p><a
href="http://wordpressapi.com/files/passenger_preference_pane.png"><img
class="alignnone size-full wp-image-3532" title="passenger_preference_pane" src="http://wordpressapi.com/files/passenger_preference_pane.png" alt="" /></a></p><p>While working with PHP, I realized that deployment of a PHP  application is far more easier as compared to deployment of a Ruby on  Rails application. So I was wondering if there could be a way to deploy a  Ruby on Rails application in a similar fashion, as easy as you check  out the Rails project in a directory on the server, configure a  VirtualHost in the webserver, restart the webserver and there you go,  everything should work as expected.</p><p>Luckily I did find a saviour,</p><p><strong>“Phusion Passenger” a.k.a “mod_rails” or “mod_rack”</strong></p><p>Here I am putting down steps to ride Rails on Passenger.</p><p><strong>Install Passenger</strong></p><p>Passenger is available as a Rubygem. As root,</p><p><code>gem install passenger</code></p><p><strong>Install Passenger module for Apache</strong></p><p><code>passenger-install-apache2-module</code></p><p>During installation it will prompt:</p><blockquote><p>The Apache2 module was successfully installed.</p><p>Please edit your Apache configuration file, and add these lines:</p><p><code>LoadModule passenger_module  /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so<br
/> PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.11<br
/> PassengerRuby /usr/bin/ruby</code></p></blockquote><p>NOTE: Do NOT copy-paste from here. Make sure you add the lines that  passenger prompts you with.<br
/> It is specific to the OS installation. Mine was a Fedora Core 10 64-bit  installation.</p><p>Next, it will help you to configure a VirtualHost for Apache</p><blockquote><p><code>&lt;VirtualHost *:80&gt;<br
/> ServerName www.yourhost.com<br
/> DocumentRoot /somewhere/public</code></p><p><code> &lt;Directory /somewhere/public&gt;<br
/> AllowOverride all<br
/> Options -MultiViews<br
/> &lt;/Directory&gt;</code></p><p><code>&lt;/VirtualHost&gt;</code></p></blockquote><p><strong>Restart Apache:</strong></p><p>As root,</p><p><code>/sbin/service httpd restart</code></p><p>That&#8217;s it, we are done.<br
/> Point your browser to your domain, and you should be able to see your  Ruby on Rails Application.</p><p>Do keep in mind that the default Rails environment while using  Passenger is “production”<br
/> To access your application in “development” or any other environment add  the following line in your VirtualHost configuration:</p><p><code>RailsEnv development</code></p><p><strong>Restarting your application deployed in production  environment:</strong></p><p>To restart your Rails application deployed in production environment  you can restart Apache.<br
/> But that&#8217;s not a good solution if you are hosting multiple applications  on the same server, or even generally, it doesn&#8217;t sound like a good idea  to restart Apache every now and then.<br
/> To overcome that, you can restart your application in the following way:</p><p>From Rails Root Directory,</p><p><code>touch tmp/restart.txt</code></p><p>That&#8217;s it, this will restart you Rails application.</p><p>The best part is, Passenger is compatible with all the Rubygems and  Rails plugins.</p><p>So nothing should break. I personally tried running a complex Rails  application that uses Solr as the search engine along with acts_as_solr  plugin, backgroundRB server for background processes, attachment_fu for  file uploads etc, etc.</p><p>Everything worked like a charm.</p><p>For further configuration, please refer to the Passenger  documentation found <a
href="http://www.modrails.com/documentation/Users%20guide%20Apache.html#_configuring_phusion_passenger" target="_blank">here</a>:</p><p>You can also use Passenger to serve Non-Rails Ruby web applications.  That can be a good alternative to the already prevalent <strong>mod_ruby</strong> module for Apache.<br
/> If you are using Nginx as your webserver, you can use Passenger module  for Nginx.</p><p>There&#8217;s just one disadvantage to Passenger:</p><p><strong>It doesn&#8217;t work on Windows</strong>. In any case, I  personally never prefer to develop Rails (or any other) applications on  Windows <img
src='http://wordpressapi.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Good news for Mac users:</p><p><a
href="http://www.google.co.in/url?sa=t&amp;source=web&amp;ct=res&amp;cd=5&amp;ved=0CBkQFjAE&amp;url=http%3A%2F%2Fwww.fngtps.com%2F2008%2F12%2Fpassenger-preference-pane-v1-2&amp;rct=j&amp;q=rails+passenger+pref+pane&amp;ei=nTmrS9PcNpXk7AO_huGzDw&amp;usg=AFQjCNHP1ra5YDrzjpu7eNE74O9dlh9Rqw" target="_blank">fingertips</a> has come up with an OS X preference pane  for Phusion Passenger (a.k.a. mod_rails) that makes it a cinch to  deploy Rails applications using Passenger on the Mac. It can be as  simple as dragging a Rails application folder onto the preference pane!  This is absolutely ideal for quick and easy Rails development on OS X.</p><p>You can download the <strong>Passenger Preference Pane</strong> <a
href="http://go2.wordpress.com/?id=725X1342&amp;site=adhirajrankhambe.wordpress.com&amp;url=http%3A%2F%2Fwww.fngtps.com%2Fpassenger-preference-pane&amp;sref=http%3A%2F%2Fadhirajrankhambe.wordpress.com%2F2010%2F03%2F20%2Friding-rails-the-php-way%2F" target="_blank">here</a></p><p><strong>References:</strong></p><p><a
href="http://www.modrails.com/documentation/Users%20guide%20Apache.html" target="_blank">http://www.modrails.com/documentation/Users%20guide%20Apache.html</a></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/06/23/deploy-rails-website-passenger-rails-deployment-passenger/feed/</wfw:commentRss> <slash:comments>20</slash:comments> </item> <item><title>Ruby 1.9.1 is came with performance improvement of 63%</title><link>http://wordpressapi.com/2010/02/27/ruby-1-9-1-performance-improvement-63/</link> <comments>http://wordpressapi.com/2010/02/27/ruby-1-9-1-performance-improvement-63/#comments</comments> <pubDate>Sat, 27 Feb 2010 18:34:32 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[news]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=1624</guid> <description><![CDATA[Ruby is very powerful object oriented language. Working with pure Ruby is really fun and interesting to me. I am real fan of Ruby language. I am working Ruby on Rails for around last four years. There is always I am thinking and all ROR developers are thinking about performance of application. We always compare.....]]></description> <content:encoded><![CDATA[<p>Ruby is very powerful object oriented language. Working with pure Ruby is really fun and interesting to me. I am real fan of Ruby language.</p><p>I am working Ruby on Rails for around last four years. There is always I am thinking and all ROR developers are thinking about performance of application.</p><p>We always compare Ruby on Rails with PHP, Java, Python, dot net. We came to know that where we are lacking in ROR. Just one issue performance and memory issue.</p><p>When we got news about Ruby 1.9 is comming with performance improvement of 63%. Yes, It is not a joke. This is really great news for every ROR developers. Ruby 1.9 and Rails 3.0 is the future of internet.</p><p>Now I will talk about Ruby Software engineer who developed and worked on the Ruby 1.9.</p><p><a
href="http://wordpressapi.com/files/Masahiro-Kanai.jpg"><img
class="alignleft size-medium wp-image-1625" style="margin: 5px" title="Masahiro Kanai" src="http://wordpressapi.com/files/Masahiro-Kanai-300x300.jpg" alt="" width="300" height="300" /></a><strong>Masahiro Kanai, </strong>who improved the performance of several methods in Ruby 1.9. He is the age of high school, just 17.</p><p>This year, Ruby 1.9 by the Fibonacci sequence of operations (multiple-precision addition) is,<br
/> Ruby 1.8 is slower than I realized Mr. Kanai is a challenge to freedom of choice camp Ruby faster.</p><p>In front of all the participants had a similar problem occurring, Ruby of type String, Array types (structures that may have an embedded data structure type object itself) and some of the faster method, attention collection. Oden&#8217;s is known to be well-covered tongue teachers. Ruby continued even after the camp&#8217;s efforts to speed up to approximately some methods to remove the macro in a constant loop of 63 percent to about 8 percent of success in speeding. This patch has been adopted by the community of developers Ruby, Ruby has been incorporated into the trunk (October 5, 2009).</p><p>many professional engineers and developers, with patience to hold out that the problem is resolved, probably as a programmer in one or two talents.</p><p>Ketai that builds skills and career tips for the professional engineer. Interviewers are already familiar with this series, the Mr. Ikuo Takeuchi, Professor Department of Creative Informatics, Graduate School of Information Science and Engineering, University of Tokyo. This time, who undertook the voluntary and discover if training for a talented programmer.</p><p>His mentor was Koichi Sasada (ko1). The performances of the methods he worked have been bumped up 63% in maximum, 8% in average. His patches were applied to Ruby trunk in Oct. 5 this year.</p><h3>What he did for Ruby Performance tuning?</h3><p><a
href="http://wordpressapi.com/files/Masahiro-Kanai2.jpg"><img
class="alignleft size-medium wp-image-1626" style="margin: 5px" title="Masahiro Kanai2" src="http://wordpressapi.com/files/Masahiro-Kanai2-225x300.jpg" alt="" width="225" height="300" /></a>He took unnecessary macro references out from a loop. Masahiro spotted macros below in array.c, string.c, and struct.c were referred every time Ruby checked whether data was hold in a structure or not. Even though data were constants, Ruby saw the macros to judge data’s presence in every loop.</p><p>What I say now more&#8230; I am really happy and I can say this is the biggest news of 2010 in IT world.</p><p>One thing I want to mention here about Ruby on Rails. This thing is in mind of all ROR developers.</p><p>&#8220;Thank God, No need to look Jruby&#8221;</p><div
id="_mcePaste" style="overflow: hidden;width: 1px;height: 1px">He took unnecessary macro references out from a loop. Masahiro spotted macros below in array.c, string.c, and struct.c were referred every time Ruby checked whether data was hold in a structure or not. Even though data were constants, Ruby saw the macros to judge data’s presence in every loop.</div> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/02/27/ruby-1-9-1-performance-improvement-63/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Ruby on Rails 3.0 released with new features</title><link>http://wordpressapi.com/2010/02/27/ruby-rails-3-0-released-features/</link> <comments>http://wordpressapi.com/2010/02/27/ruby-rails-3-0-released-features/#comments</comments> <pubDate>Sat, 27 Feb 2010 18:07:51 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[google]]></category> <category><![CDATA[news]]></category> <category><![CDATA[technology]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[release]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=1620</guid> <description><![CDATA[I am working on Ruby on Rails for past three and half year. It is really great to working with Ruby on Rails. Because working on Ruby on Rails is a really great feeling daily inventing new things, trying new things and contributing to ROR community. Discussing new things with ROR developers is really great......]]></description> <content:encoded><![CDATA[<p><a
href="http://wordpressapi.com/files/ruby-on-rails-3.0.png"><img
class="alignleft size-medium wp-image-1621" title="ruby-on-rails-3.0" src="http://wordpressapi.com/files/ruby-on-rails-3.0-300x212.png" alt="" width="300" height="212" /></a>I am working on Ruby on Rails for past three and half year. It is really great to working with Ruby on Rails. Because working on Ruby on Rails is a really great feeling daily inventing new things, trying new things and contributing to ROR community. Discussing new things with ROR developers is really great.</p><p>On 5th Feb we got news about release of Rails 3.0 beta. We all developers are really waiting for that day. We checked the new version of Rails but what is more interesting.</p><p>The interesting part is what is new in Rails 3.0. So many developers contributed in Rails 3.0. They really worked and planned so hard.</p><p>Here I am making list what Rails 3.0  has, means new features:</p><ul><li>Brand new router with an emphasis on RESTful declarations</li><li>New Action Mailer API modelled after Action Controller (now without the agonizing pain of sending multipart messages!)</li><li>New Active Record chainable query language built on top of relational algebra</li><li>Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS)</li><li>Explicit dependency management with Bundler</li></ul><p>If you want to use the Rails 3.0 then you should install first following gems.</p><pre class="brush: ruby;">
#gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
#gem install rails --pre
</pre><p>Or you can use following command to install whole Rails 3.0 with dependencies</p><pre class="brush: ruby;">
gem uninstall rubygems-update
gem update --system
#gem install rails3b
</pre><p><strong>Important Note: </strong>Rails 3 requires Ruby 1.8.7+ , you should install latest Ruby version. You can download latest Ruby version from here.</p><p><a
href="http://www.ruby-lang.org/en/downloads/" target="_blank">Ruby 1.9.1</a></p><p>Here I am giving the list of gems and plugins which are compilable of Rails 3.0. you should check the following URL:</p><p><a
href="http://wiki.rubyonrails.org/rails/version3/plugins_and_gems">http://wiki.rubyonrails.org/rails/version3/plugins_and_gems</a></p><p>Now I am started working on Rails 3.0 and I am searching for the issues with Rails 3.0 because Rails 3.0 is in Beta so all ROR developer need to come up with issues of Rails 3.0 and try to fix that or submit that issue to community.</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/02/27/ruby-rails-3-0-released-features/feed/</wfw:commentRss> <slash:comments>22</slash:comments> </item> <item><title>Rails 3 beta by February</title><link>http://wordpressapi.com/2010/02/02/rails-3-beta-february/</link> <comments>http://wordpressapi.com/2010/02/02/rails-3-beta-february/#comments</comments> <pubDate>Tue, 02 Feb 2010 09:43:23 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://wordpressapi.com/?p=735</guid> <description><![CDATA[Ruby on Rails 3, an upgrade to the popular Web development framework that merges Rails with the alternative Merb framework, is due to be offered as a beta release by the end of this month. According to David Heinemeier Hansson, the founder of the Ruby based web development framework, although a beta of Rails 3.....]]></description> <content:encoded><![CDATA[<p
style="margin-bottom: 0in">Ruby on Rails 3, an upgrade to the popular Web development framework that merges Rails with the alternative Merb framework, is due to be offered as a beta release by the end of this month.</p><p
style="margin-bottom: 0in"><a
href="http://wordpressapi.com/files/ruby_on_rails_logo.jpg"><img
class="alignnone size-thumbnail wp-image-736" title="ruby_on_rails_logo" src="http://wordpressapi.com/files/ruby_on_rails_logo-150x150.jpg" alt="ruby_on_rails_logo" width="150" height="150" /></a></p><p
style="margin-bottom: 0in">According to David Heinemeier Hansson, the founder of the Ruby based web development framework, although a beta of Rails 3 is expected by the end of this month the release may slip into February. Hansson gave the estimated release timing in an article on InfoWorld. If all goes to plan Rails 3 is expected to arrive in the first quarter of this year. Rails 3 is a major reworking of the framework which sees ideas from the alternative Merb framework being integrated in a development process which began in December 2008.</p><p
style="margin-bottom: 0in"><p
style="margin-bottom: 0in">Source Articles</p><p
style="margin-bottom: 0in">http://www.engineyard.com/blog/2009/my-five-favorite-things-about-rails-3/</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2010/02/02/rails-3-beta-february/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>How to host multiple rails site on Nginx</title><link>http://wordpressapi.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/</link> <comments>http://wordpressapi.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/#comments</comments> <pubDate>Wed, 18 Nov 2009 07:28:18 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Nginx]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[Rails]]></category><guid
isPermaLink="false">http://purab.wordpress.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/</guid> <description><![CDATA[User following code in Nginx.conf file.. and paste into that file #vim /etc/nginx/nginx.conf http { include       /etc/nginx/mime.types; default_type  application/octet-stream; access_log  /var/log/nginx/access.log  main; sendfile        on; upstream mongrel_cluster_example1 { server 127.0.0.1:8000; server 127.0.0.1:8001; server 127.0.0.1:8002; } upstream mongrel_cluster_example2 { server 127.0.0.1:3000; server 127.0.0.1:3001; server 127.0.0.1:3002; } # Load config files from the /etc/nginx/conf.d directory include /etc/nginx/conf.d/*.conf; server.....]]></description> <content:encoded><![CDATA[<p>User following code in Nginx.conf file.. and paste into that file<br
/> #vim /etc/nginx/nginx.conf</p><pre class="brush: ruby;">

http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;
access_log  /var/log/nginx/access.log  main;
sendfile        on;

upstream mongrel_cluster_example1 {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}

upstream mongrel_cluster_example2 {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}

# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;

server {
listen       80;
server_name  example1.com example2.net;
client_max_body_size 120M;

set $myroot /var/www/html;
if ($host ~* example1\.com$) {
set $myroot /home/example1/public;
}

if ($host ~* example2\.net$) {
set $myroot /home/example2/public;
}

root $myroot;

location ~* ^/(images|stylesheets|javascripts).+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root $myroot;
}

location / {

if ($host ~* example1\.com$) {
proxy_pass      http://mongrel_cluster_example1;
} #if check for domain qa.teenangel ends here

if ($host ~* example2\.net$) {
root /home/rail_project/myproject/public;
proxy_pass      http://mongrel_cluster_example2;

} #if check for domain ends here

}

}

}
</pre>]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/11/18/how-to-host-multiple-rails-site-on-nginx/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>USA State list for Rails</title><link>http://wordpressapi.com/2009/11/17/usa-state-list-for-rails/</link> <comments>http://wordpressapi.com/2009/11/17/usa-state-list-for-rails/#comments</comments> <pubDate>Tue, 17 Nov 2009 12:14:20 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://purab.wordpress.com/2009/11/17/usa-state-list-for-rails/</guid> <description><![CDATA[Every time we need this migration script for our projects Use following command for Model generate [siwan@localhost siwan]$ ruby script/generate model UsStates exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/us_states.rb create test/unit/us_states_test.rb create test/fixtures/us_states.yml exists db/migrate create db/migrate/20091117115011_create_us_states.rb [siwan@localhost siwan]$ Open the /db/migrate/20091117115011_create_us_states.rb file and paste following code: class CreateUsStates &#8216;Alabama&#8217;, :abbreviation =&#62; &#8216;AL&#8217; UsStates.create.....]]></description> <content:encoded><![CDATA[<p>Every time we need this migration script for our projects<br
/> Use following command for Model generate<br
/> [siwan@localhost siwan]$ ruby script/generate model UsStates<br
/> exists  app/models/<br
/> exists  test/unit/<br
/> exists  test/fixtures/<br
/> create  app/models/us_states.rb<br
/> create  test/unit/us_states_test.rb<br
/> create  test/fixtures/us_states.yml<br
/> exists  db/migrate<br
/> create  db/migrate/20091117115011_create_us_states.rb<br
/> [siwan@localhost siwan]$</p><p>Open the /db/migrate/20091117115011_create_us_states.rb file and paste following code:</p><p>class CreateUsStates  &#8216;Alabama&#8217;, :abbreviation =&gt; &#8216;AL&#8217;<br
/> UsStates.create :name =&gt; &#8216;Alaska&#8217;, :abbreviation =&gt; &#8216;AK&#8217;<br
/> UsStates.create :name =&gt; &#8216;Arizona&#8217;, :abbreviation =&gt; &#8216;AZ&#8217;<br
/> UsStates.create :name =&gt; &#8216;Arkansas&#8217;, :abbreviation =&gt; &#8216;AR&#8217;<br
/> UsStates.create :name =&gt; &#8216;California&#8217;, :abbreviation =&gt; &#8216;CA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Colorado&#8217;, :abbreviation =&gt; &#8216;CO&#8217;<br
/> UsStates.create :name =&gt; &#8216;Connecticut&#8217;, :abbreviation =&gt; &#8216;CT&#8217;<br
/> UsStates.create :name =&gt; &#8216;Delaware&#8217;, :abbreviation =&gt; &#8216;DE&#8217;<br
/> UsStates.create :name =&gt; &#8216;District of Columbia&#8217;, :abbreviation =&gt; &#8216;DC&#8217;<br
/> UsStates.create :name =&gt; &#8216;Florida&#8217;, :abbreviation =&gt; &#8216;FL&#8217;<br
/> UsStates.create :name =&gt; &#8216;Georgia&#8217;, :abbreviation =&gt; &#8216;GA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Hawaii&#8217;, :abbreviation =&gt; &#8216;HI&#8217;<br
/> UsStates.create :name =&gt; &#8216;Idaho&#8217;, :abbreviation =&gt; &#8216;ID&#8217;<br
/> UsStates.create :name =&gt; &#8216;Illinois&#8217;, :abbreviation =&gt; &#8216;IL&#8217;<br
/> UsStates.create :name =&gt; &#8216;Indiana&#8217;, :abbreviation =&gt; &#8216;IN&#8217;<br
/> UsStates.create :name =&gt; &#8216;Iowa&#8217;, :abbreviation =&gt; &#8216;IA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Kansas&#8217;, :abbreviation =&gt; &#8216;KS&#8217;<br
/> UsStates.create :name =&gt; &#8216;Kentucky&#8217;, :abbreviation =&gt; &#8216;KY&#8217;<br
/> UsStates.create :name =&gt; &#8216;Louisiana&#8217;, :abbreviation =&gt; &#8216;LA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Maine&#8217;, :abbreviation =&gt; &#8216;ME&#8217;<br
/> UsStates.create :name =&gt; &#8216;Maryland&#8217;, :abbreviation =&gt; &#8216;MD&#8217;<br
/> UsStates.create :name =&gt; &#8216;Massachutsetts&#8217;, :abbreviation =&gt; &#8216;MA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Michigan&#8217;, :abbreviation =&gt; &#8216;MI&#8217;<br
/> UsStates.create :name =&gt; &#8216;Minnesota&#8217;, :abbreviation =&gt; &#8216;MN&#8217;<br
/> UsStates.create :name =&gt; &#8216;Mississippi&#8217;, :abbreviation =&gt; &#8216;MS&#8217;<br
/> UsStates.create :name =&gt; &#8216;Missouri&#8217;, :abbreviation =&gt; &#8216;MO&#8217;<br
/> UsStates.create :name =&gt; &#8216;Montana&#8217;, :abbreviation =&gt; &#8216;MT&#8217;<br
/> UsStates.create :name =&gt; &#8216;Nebraska&#8217;, :abbreviation =&gt; &#8216;NE&#8217;<br
/> UsStates.create :name =&gt; &#8216;Nevada&#8217;, :abbreviation =&gt; &#8216;NV&#8217;<br
/> UsStates.create :name =&gt; &#8216;New Hampshire&#8217;, :abbreviation =&gt; &#8216;NH&#8217;<br
/> UsStates.create :name =&gt; &#8216;New Jersey&#8217;, :abbreviation =&gt; &#8216;NJ&#8217;<br
/> UsStates.create :name =&gt; &#8216;New Mexico&#8217;, :abbreviation =&gt; &#8216;NM&#8217;<br
/> UsStates.create :name =&gt; &#8216;New York&#8217;, :abbreviation =&gt; &#8216;NY&#8217;<br
/> UsStates.create :name =&gt; &#8216;North Carolina&#8217;, :abbreviation =&gt; &#8216;NC&#8217;<br
/> UsStates.create :name =&gt; &#8216;North Dakota&#8217;, :abbreviation =&gt; &#8216;ND&#8217;<br
/> UsStates.create :name =&gt; &#8216;Ohio&#8217;, :abbreviation =&gt; &#8216;OH&#8217;<br
/> UsStates.create :name =&gt; &#8216;Oklahoma&#8217;, :abbreviation =&gt; &#8216;OK&#8217;<br
/> UsStates.create :name =&gt; &#8216;Oregon&#8217;, :abbreviation =&gt; &#8216;OR&#8217;<br
/> UsStates.create :name =&gt; &#8216;Pennsylvania&#8217;, :abbreviation =&gt; &#8216;PA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Rhode Island&#8217;, :abbreviation =&gt; &#8216;RI&#8217;<br
/> UsStates.create :name =&gt; &#8216;South Carolina&#8217;, :abbreviation =&gt; &#8216;SC&#8217;<br
/> UsStates.create :name =&gt; &#8216;South Dakota&#8217;, :abbreviation =&gt; &#8216;SD&#8217;<br
/> UsStates.create :name =&gt; &#8216;Tennessee&#8217;, :abbreviation =&gt; &#8216;TN&#8217;<br
/> UsStates.create :name =&gt; &#8216;Texas&#8217;, :abbreviation =&gt; &#8216;TX&#8217;<br
/> UsStates.create :name =&gt; &#8216;Utah&#8217;, :abbreviation =&gt; &#8216;UT&#8217;<br
/> UsStates.create :name =&gt; &#8216;Vermont&#8217;, :abbreviation =&gt; &#8216;VT&#8217;<br
/> UsStates.create :name =&gt; &#8216;Virginia&#8217;, :abbreviation =&gt; &#8216;VA&#8217;<br
/> UsStates.create :name =&gt; &#8216;Washington&#8217;, :abbreviation =&gt; &#8216;WA&#8217;<br
/> UsStates.create :name =&gt; &#8216;West Virginia&#8217;, :abbreviation =&gt; &#8216;WV&#8217;<br
/> UsStates.create :name =&gt; &#8216;Wisconsin&#8217;, :abbreviation =&gt; &#8216;WI&#8217;<br
/> UsStates.create :name =&gt; &#8216;Wyoming&#8217;, :abbreviation =&gt; &#8216;WY&#8217;</p><p>end</p><p>def self.down<br
/> drop_table :us_states<br
/> end<br
/> end</p><p>Goodlunk, This code will save your problem of fetching USA state names and abbreviations as per id</p><p>Check my controller code&#8230;Just put in your controller</p><p>@us_states = USStates.find(:all)</p><p>&lt;% form_for :customer, @customer, :url =&gt; { :action =&gt; &#8220;new_application&#8221; } do |f| %&gt;<br
/> &lt;%= f.select :state_id,  @us_states.collect {|state| [ state.abbreviation, state.id ] } %&gt;<br
/> &lt;% end %&gt;</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/11/17/usa-state-list-for-rails/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Issue with installing the mysql gem: solved, how to install mysql gem without issue</title><link>http://wordpressapi.com/2009/11/17/issue-with-installing-the-mysql-gem-solved-how-to-install-mysql-gem-without-issue/</link> <comments>http://wordpressapi.com/2009/11/17/issue-with-installing-the-mysql-gem-solved-how-to-install-mysql-gem-without-issue/#comments</comments> <pubDate>Tue, 17 Nov 2009 09:50:35 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[MySql]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://purab.wordpress.com/2009/11/17/issue-with-installing-the-mysql-gem-solved-how-to-install-mysql-gem-without-issue/</guid> <description><![CDATA[When tried to install mysql gem I got following error [root@localhost siwan]# sudo gem install mysql Building native extensions. This could take a while&#8230; ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb checking for mysql_ssl_set()&#8230; yes checking for rb_str_set_len()&#8230; no checking for rb_thread_start_timer()&#8230; yes checking for mysql.h&#8230; no checking for.....]]></description> <content:encoded><![CDATA[<p>When tried to install mysql gem I got following error<br
/> [root@localhost siwan]# sudo gem install mysql<br
/> Building native extensions.  This could take a while&#8230;<br
/> ERROR:  Error installing mysql:<br
/> ERROR: Failed to build gem native extension.</p><p>/usr/bin/ruby extconf.rb<br
/> checking for mysql_ssl_set()&#8230; yes<br
/> checking for rb_str_set_len()&#8230; no<br
/> checking for rb_thread_start_timer()&#8230; yes<br
/> checking for mysql.h&#8230; no<br
/> checking for mysql/mysql.h&#8230; no<br
/> *** extconf.rb failed ***<br
/> Could not create Makefile due to some reason, probably lack of<br
/> necessary libraries and/or headers.  Check the mkmf.log file for more<br
/> details.  You may need configuration options.</p><p>Provided configuration options:<br
/> &#8211;with-opt-dir<br
/> &#8211;without-opt-dir<br
/> &#8211;with-opt-include<br
/> &#8211;without-opt-include=${opt-dir}/include<br
/> &#8211;with-opt-lib<br
/> &#8211;without-opt-lib=${opt-dir}/lib<br
/> &#8211;with-make-prog<br
/> &#8211;without-make-prog<br
/> &#8211;srcdir=.<br
/> &#8211;curdir<br
/> &#8211;ruby=/usr/bin/ruby<br
/> &#8211;with-mysql-config<br
/> &#8211;without-mysql-config</p><p>Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.<br
/> Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out</p><p>To find the mysql path on machine used following command<br
/> [root@localhost siwan]# which mysql<br
/> /usr/bin/mysql</p><p>I tried following command:<br
/> [root@localhost siwan]# sudo gem install mysql — –with-mysql-dir=/usr/bin/mysql</p><p>I Got the same error</p><p>[root@localhost siwan]# sudo gem install mysql — –with-mysql-dir=/usr/bin/mysql<br
/> Building native extensions.  This could take a while&#8230;<br
/> ERROR:  Error installing mysql:<br
/> ERROR: Failed to build gem native extension.</p><p>/usr/bin/ruby extconf.rb<br
/> checking for mysql_ssl_set()&#8230; yes<br
/> checking for rb_str_set_len()&#8230; no<br
/> checking for rb_thread_start_timer()&#8230; yes<br
/> checking for mysql.h&#8230; no<br
/> checking for mysql/mysql.h&#8230; no<br
/> *** extconf.rb failed ***<br
/> Could not create Makefile due to some reason, probably lack of<br
/> necessary libraries and/or headers.  Check the mkmf.log file for more<br
/> details.  You may need configuration options.</p><p>Provided configuration options:<br
/> &#8211;with-opt-dir<br
/> &#8211;without-opt-dir<br
/> &#8211;with-opt-include<br
/> &#8211;without-opt-include=${opt-dir}/include<br
/> &#8211;with-opt-lib<br
/> &#8211;without-opt-lib=${opt-dir}/lib<br
/> &#8211;with-make-prog<br
/> &#8211;without-make-prog<br
/> &#8211;srcdir=.<br
/> &#8211;curdir<br
/> &#8211;ruby=/usr/bin/ruby<br
/> &#8211;with-mysql-config<br
/> &#8211;without-mysql-config</p><p>Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.<br
/> Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out<br
/> ERROR:  could not find gem — locally or in a repository<br
/> ERROR:  could not find gem –with-mysql-dir=/usr/bin/mysql locally or in a repository</p><p>Then I checked the mysql-devel<br
/> [root@localhost siwan]# yum list mysql-devel<br
/> Loaded plugins: refresh-packagekit<br
/> Available Packages<br
/> mysql-devel.i586                                              5.1.37-1.fc11                                               updates</p><p>Then I Installed the mysql-devel<br
/> [root@localhost siwan]# yum install mysql-devel<br
/> Installed:<br
/> mysql-devel.i586 0:5.1.37-1.fc11<br
/> Complete!</p><p>Then I tried the mysql Gem installing&#8230;..I am able to install the mysql gem&#8230;<br
/> [root@localhost siwan]# gem install mysql<br
/> Building native extensions.  This could take a while&#8230;<br
/> Successfully installed mysql-2.8.1<br
/> 1 gem installed<br
/> Installing ri documentation for mysql-2.8.1&#8230;<br
/> Installing RDoc documentation for mysql-2.8.1&#8230;<br
/> [root@localhost siwan]#</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/11/17/issue-with-installing-the-mysql-gem-solved-how-to-install-mysql-gem-without-issue/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>How to setup mongrel cluster setup on fedora</title><link>http://wordpressapi.com/2009/11/02/how-to-setup-mongrel-cluster-setup-on-fedora/</link> <comments>http://wordpressapi.com/2009/11/02/how-to-setup-mongrel-cluster-setup-on-fedora/#comments</comments> <pubDate>Mon, 02 Nov 2009 13:46:43 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Apache]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySql]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[mongrel]]></category> <category><![CDATA[mongrel_cluster]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=293</guid> <description><![CDATA[First install the following gems: #su #gem install mongrel #gem install mongrel_cluster #cd project_name #mongrel_rails cluster::configure -e production -p 3000 -N 3 -c /home/siwan/project_name -a 127.0.0.1 &#8212;-prefix /project_name # mongrel_rails cluster::start You are able to start your applicaton at http://127.0.0.1:3000, http://127.0.0.1:3001 and http://127.0.0.1:3002 for all the cluster # mongrel_rails cluster::stop Advanced prepairation for production realeaze.....]]></description> <content:encoded><![CDATA[<p>First install the following gems:<br
/> #su<br
/> #gem install mongrel<br
/> #gem install mongrel_cluster<br
/> #cd project_name<br
/> #mongrel_rails cluster::configure -e production -p 3000 -N 3 -c /home/siwan/project_name -a 127.0.0.1 &#8212;-prefix /project_name<br
/> # mongrel_rails cluster::start</p><p>You are able to start your applicaton at http://127.0.0.1:3000, http://127.0.0.1:3001 and http://127.0.0.1:3002</p><p>for all the cluster<br
/> # mongrel_rails cluster::stop</p><p>Advanced prepairation for production realeaze<br
/> $ mkdir /etc/mongrel_cluster</p><p>#vim /etc/mongrel_cluster/project_name.yml<br
/> copy and paste following text;<br
/> user: project_name<br
/> cwd: //home/siwan/project_name<br
/> log_file: /home/siwan/project_name/mongrel.log<br
/> port: &#8220;3000&#8243;<br
/> environment: production<br
/> group: dev<br
/> address: localhost<br
/> pid_file: /home/siwan/project_name/tmp/pids/mongrel.pid<br
/> servers: 3</p><p>or you can run the following command</p><p>or copy and paste the content from config/mongrel_cluster.yml file to /etc/mongrel_cluster/project_name.yml</p><p># ln -s /home/siwan/project_name/config/mongrel_cluster.yml /etc/mongrel_cluster/project_name.yml</p><p>Then open your httpd.conf file for apache configration:</p><p>&lt;Proxy balancer://project_name&gt;<br
/> BalancerMember http://127.0.0.1:3000<br
/> BalancerMember http://127.0.0.1:3001<br
/> BalancerMember http://127.0.0.1:3002<br
/> &lt;/Proxy&gt;</p><p>&lt;VirtualHost *:80&gt;<br
/> ProxyPreserveHost On<br
/> # Avoid open you server to proxying<br
/> ProxyRequests Off<br
/> # Options +FollowSymLinks<br
/> RewriteEngine On</p><p>RewriteRule ^/(images|stylesheet|javascript|html)/?(.*) /home/siwan/project_name/public/$0 [L]<br
/> ServerAdmin siwan@yahoo.co.in<br
/> DocumentRoot /home/project_name/<br
/> ServerName example.com<br
/> RewriteRule  ^/(.*)$  balancer://project_name%{REQUEST_URI} [P,QSA,L]<br
/> &lt;/VirtualHost&gt;</p><p>Restart the apache server<br
/> #/etc/init.d/httpd restart</p><p>Command for restart the mongrel servers from any where<br
/> # mongrel_rails cluster::restart -C /etc/mongrel_cluster/project_name.yml</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/11/02/how-to-setup-mongrel-cluster-setup-on-fedora/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Use PHP in Rails project</title><link>http://wordpressapi.com/2009/09/15/use-php-in-rails-project/</link> <comments>http://wordpressapi.com/2009/09/15/use-php-in-rails-project/#comments</comments> <pubDate>Tue, 15 Sep 2009 11:36:34 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[scripts]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=234</guid> <description><![CDATA[Many times you need to use PHP scripts in Rails project. You will got so much open source PHP scripts for various use. Example is So many Rails site is using WordPress for blogging system. Main reason behind using PHP files or script is SEO. PHP is a very SEO friendly. Customer does not want.....]]></description> <content:encoded><![CDATA[<p>Many times you need to use PHP scripts in Rails project. You will got so much open source PHP scripts for various use.</p><p>Example is So many Rails site is using WordPress for blogging system.</p><p>Main reason behind using PHP files or script is SEO. PHP is a very SEO friendly.</p><p>Customer does not want to spend money or time already existing scripts or program.</p><p>If you want to use PHP files or project under Rails project. Just create any folder in Public directory and put your php files in to that folder.</p><p>lets say you created the &#8220;fourm&#8221; dir in public directory.</p><p>You need to add following lines in your apache rule file(httpd.conf)</p><p><span
style="color:#0000ff">LoadModule proxy_module modules/mod_proxy.so</span></p><p><span
style="color:#0000ff">LoadModule proxy_http_module modules/mod_proxy_http.so</span></p><p>Under &lt;VirtualHost  *:80&gt; tag add following lines:</p><p><span
style="color:#0000ff">ProxyRequests Off</span></p><p><span
style="color:#0000ff">RewriteEngine On</span></p><p><span
style="color:#0000ff">RewriteCond  %{HTTP_HOST}    ^example.com [NC]<br
/> RewriteCond %{REQUEST_URI}  !^/forum(.*)$ [NC]</span></p><p><span
style="color:#0000ff">RewriteCond  %{HTTP_HOST}    ^example.com [NC]</span></p><p><span
style="color:#0000ff"> RewriteRule ^/forum/?(.*)$ /document_root/forum/$1 [QSA,NC,L]</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">Than you are able to use PHP code or scripts in Rails project</span><br
/> </span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/15/use-php-in-rails-project/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>How to use juggernaut in Rails project</title><link>http://wordpressapi.com/2009/09/15/how-to-use-juggernaut-in-rails-project/</link> <comments>http://wordpressapi.com/2009/09/15/how-to-use-juggernaut-in-rails-project/#comments</comments> <pubDate>Tue, 15 Sep 2009 10:35:00 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[chat]]></category> <category><![CDATA[data]]></category> <category><![CDATA[juggernaut]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[Server]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=232</guid> <description><![CDATA[Juggernaut is the Rails plugin for sending and receiving data in different thread. It gives you real time connection to server and you can implement different ideas work or fulfil your requirement. Juggernaut uses the eventmachine as a server. So install the supported gem first. #gem install json #gem install eventmachine #gem install juggernaut Juggernaut.....]]></description> <content:encoded><![CDATA[<p>Juggernaut is the Rails plugin for sending and receiving data in different thread. It gives you real time connection to server and you can implement different ideas work or fulfil your requirement.</p><p>Juggernaut uses the eventmachine as a server.</p><p>So install the supported gem first.</p><p><span
style="color:#0000ff">#gem install json</span></p><p><span
style="color:#0000ff">#gem install eventmachine</span></p><p><span
style="color:#0000ff">#gem install juggernaut</span></p><p>Juggernaut is aims to revolutionize your Rails  app by letting the server initiate a connection and push data to the  client.</p><p>Juggernaut is used for speciallycreating Chat application.</p><p>If you want to full details about Juggernaut then go to <a
href="http://juggernaut.rubyforge.org/" target="_blank">http://juggernaut.rubyforge.org/</a></p><p>First install the juggernaut to your application using this command.<br
/> <span
style="color:#0000ff"> ruby script/plugin install git://github.com/maccman/juggernaut_plugin.git</span></p><p>install the gem : <span
style="color:#0000ff">gem install juggernaut</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">Configure the gem: </span></span>juggernaut -<span
style="color:#0000ff">g juggernaut.yml</span></p><p>Start the Juggernaut server: <span
style="color:#0000ff">juggernaut -c juggernaut.yml</span></p><p>(This is not rails server or mongrel server)</p><p>In your controller you can use this method to send data to Juggernaut server</p><p><span
style="color:#0000ff">Juggernaut.send_to_all(&#8220;alert(&#8216;hi from juggernaut&#8217;)&#8221;)</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">If you want customize the Juggernaut methods or add new methods then open file:<br
/> </span></span></p><p><span
style="color:#0000ff">/vender/plugin/juggernaut_plugin/lib/juggernaut.rb</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">Add your methods there and use in your projects.<br
/> </span></span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/15/how-to-use-juggernaut-in-rails-project/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>link_to with image_tag in Rails</title><link>http://wordpressapi.com/2009/09/15/link_to-with-image_tag-in-rails/</link> <comments>http://wordpressapi.com/2009/09/15/link_to-with-image_tag-in-rails/#comments</comments> <pubDate>Tue, 15 Sep 2009 10:17:46 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[form]]></category> <category><![CDATA[image]]></category> <category><![CDATA[image_tag]]></category> <category><![CDATA[link_to]]></category> <category><![CDATA[Rails]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=230</guid> <description><![CDATA[This is very basic form tag in rails. but some time you get confused about using this tag. How to displays a image inside link_to instead of text? Here is answer: &#60;%= link_to image_tag(&#8220;/images/submit.jpg&#8221;, :border=&#62;0), :action =&#62; &#8216;create&#8217; %&#62; Section Option: &#60;%= link_to image_tag(&#8220;/images/submit.jpg&#8221;, :border=&#62;0,:class=&#62;&#8217;sub20&#8242;), :url =&#62;{:controller=&#62; &#8216;user&#8217;,:action=&#62;&#8217;create&#8217;}  %&#62;]]></description> <content:encoded><![CDATA[<p>This is very basic form tag in rails. but some time you get confused about using this tag.</p><p>How to displays a image inside <em>link_to</em> instead of text?</p><p>Here is answer:<br
/> <span
style="color:#0000ff">&lt;%= link_to image_tag(&#8220;/images/submit.jpg&#8221;, :border=&gt;0), :action =&gt; &#8216;create&#8217; %&gt;</span></p><p>Section Option:</p><p><span
style="color:#0000ff">&lt;%= link_to image_tag(&#8220;/images/submit.jpg&#8221;, :border=&gt;0,:class=&gt;&#8217;sub20&#8242;), :url =&gt;{:controller=&gt; &#8216;user&#8217;,:action=&gt;&#8217;create&#8217;}  %&gt;</span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/15/link_to-with-image_tag-in-rails/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Create XML document with Ruby -XML parsing</title><link>http://wordpressapi.com/2009/09/14/create-xml-document-with-ruby-xml-parsing/</link> <comments>http://wordpressapi.com/2009/09/14/create-xml-document-with-ruby-xml-parsing/#comments</comments> <pubDate>Mon, 14 Sep 2009 13:23:32 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[paring]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[xml]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=222</guid> <description><![CDATA[XML is most popular data transfer layer. In every language we need XML parsing. In Ruby there is in build XML strong parsing support. In this post I am going to cover the How to create XML file with simple Ruby code. TIP: If you are new in Rails than follow step one or go.....]]></description> <content:encoded><![CDATA[<p>XML is most popular data transfer layer.</p><p>In every language we need XML parsing. In Ruby there is in build XML strong parsing support.</p><p>In this post I am going to cover the How to create XML file with simple Ruby code.</p><p>TIP: If you are new in Rails than follow step one or go to step two.</p><p>1. You need to install Ruby on your computer</p><p><a
href="http://www.ruby-lang.org/en/" target="_blank">http://www.ruby-lang.org/en/</a></p><p>2. Open command prompt(for windows) or console(linux)</p><p>3. Create file named CreateXML.rb and copy and paste following code</p><p><span
style="color:#0000ff">require &#8220;rexml/document&#8221;<br
/> include REXML</span></p><p><span
style="color:#0000ff">string = &lt;&lt;EOF<br
/> &lt;xml&gt;<br
/> &lt;element attribute=&#8221;attr&#8221;&gt;first XML document with ruby &lt;/element&gt;<br
/> &lt;/xml&gt;<br
/> EOF<br
/> doc = Document.new string</span></p><p><span
style="color:#0000ff">print doc</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">Output will be like this</span>:</span></p><p><span
style="color:#0000ff"><a
href="http://purab.files.wordpress.com/2009/09/create-xml.png"><img
class="size-medium wp-image-223 alignleft" title="create-xml" src="http://purab.files.wordpress.com/2009/09/create-xml.png?w=300" alt="create-xml" width="509" height="407" /></a><br
/> </span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/14/create-xml-document-with-ruby-xml-parsing/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>text_area tag in Rails &#8211; Issues</title><link>http://wordpressapi.com/2009/09/11/text_area-tag-in-rails-issues/</link> <comments>http://wordpressapi.com/2009/09/11/text_area-tag-in-rails-issues/#comments</comments> <pubDate>Fri, 11 Sep 2009 09:21:59 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[scaffold]]></category> <category><![CDATA[text_area]]></category> <category><![CDATA[text_area_tag]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=220</guid> <description><![CDATA[When you start New Rails project.  Always we used scaffolding for creating simple base for out application. I used scaffolding for some methods. I got some very weird issue about tex_area tag in rails. When i check the forms textagea fields are coming with 20 rows and 40 cols default. When i tried to change.....]]></description> <content:encoded><![CDATA[<p>When you start New Rails project.  Always we used scaffolding for creating simple base for out application.</p><p>I used scaffolding for some methods. I got some very weird issue about tex_area tag in rails.</p><p>When i check the forms textagea fields are coming with 20 rows and 40 cols default. When i tried to change that is not changing even though CSS also.</p><p><span
style="color:#0000ff">&lt;textarea id=&#8221;dummy_text&#8221; rows=&#8221;20&#8243; name=&#8221;dummy_text&#8221; cols=&#8221;40&#8243;/&gt;</span></p><p>After digging into rails code i got know that Rails -&gt;Actionpack-&gt; form_helper.rb file has default setting of textarea field.</p><p><span
style="color:#0000ff">def text_area(object_name, method, options = {})<br
/> InstanceTag.new(object_name, method, self, options.delete(:object)).to_text_area_tag(options)<br
/> end</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">We can change this also. but this is not good idea</span></span></p><p><span
style="color:#0000ff"><span
style="color:#000000">so good idea is select our project and use find replace:</span></span></p><p><span
style="color:#0000ff">text_area to text_area_tag</span></p><p>This is the simplest solution.</p><p><span
style="color:#0000ff"><br
/> </span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/11/text_area-tag-in-rails-issues/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Rich Text Editor in Rails Application</title><link>http://wordpressapi.com/2009/09/10/rich-text-editor-in-rails-application/</link> <comments>http://wordpressapi.com/2009/09/10/rich-text-editor-in-rails-application/#comments</comments> <pubDate>Thu, 10 Sep 2009 12:24:51 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[tutorials]]></category> <category><![CDATA[web design]]></category> <category><![CDATA[Editor]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[RTE]]></category> <category><![CDATA[wysiwyg]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=215</guid> <description><![CDATA[Many times you need normal CMS for your application. You want to need some pages data need to handle through CMS. It is really very easy to Install any RTE in the Rails. There are many open source RTE available. I used the Cross-Browser Rich Text Editor for my project. I downloaded files from there.....]]></description> <content:encoded><![CDATA[<p>Many times you need normal CMS for your application. You want to need some pages data need to handle through CMS.</p><p>It is really very easy to Install any RTE in the Rails. There are many open source RTE available.</p><p>I used the <a
href="http://www.kevinroth.com/rte/">Cross-Browser Rich Text Editor</a> for my project.<br
/> I downloaded files from there and uploaded to my public folder. I added required CSS and JS file to my layout.</p><p>You need to add following lines to your application.html.erb file.(you will find this file in view/layout/ folder)</p><p>1. You can add that files on conditional base also. Means for that particular page.<br
/> 2. Add following lines to your form<br
/> <span
style="color:#0000ff">:html =&gt; { :name =&gt; &#8216;BlogRTE&#8217;, <img
src='http://wordpressapi.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nsubmit =&gt; &#8220;submitForm();&#8221;} </span></p><p>In to add following lines to your form;</p><p><span
style="color:#0000ff">&lt;script language=&#8221;JavaScript&#8221; type=&#8221;text/javascript&#8221;&gt;<br
/> &lt;!&#8211;<br
/> function submitForm() {<br
/> updateRTEs();<br
/> return false;<br
/> }<br
/> initRTE(&#8220;/cbrte/images/&#8221;, &#8220;/cbrte/&#8221;, &#8220;&#8221;, true);<br
/> //&#8211;&gt;<br
/> &lt;/script&gt;<br
/> &lt;noscript&gt;&lt;p&gt;&lt;b&gt;Javascript must be enabled to use this form.&lt;/b&gt;&lt;/p&gt;&lt;/noscript&gt;<br
/> &lt;script language=&#8221;JavaScript&#8221; type=&#8221;text/javascript&#8221;&gt;<br
/> &lt;!&#8211;<br
/> //build new richTextEditor<br
/> var rte1 = new richTextEditor(&#8216;text_content&#8217;);<br
/> rte1.html = &#8216;Write your thoughts here.&#8217;;<br
/> rte1.toggleSrc = true;<br
/> rte1.width = 500;<br
/> rte1.build();<br
/> //&#8211;&gt;<br
/> &lt;/script&gt;</span></p><p>You will get the text_content params in Rails.</p><p>For Edit page functionality i got error in form. So you need to this default code for all languages.<br
/> <span
style="color:#0000ff">rte1.html =&#8221;";</span></p><p>When i used this i got an error.</p><p>But i solved this issue after some R&amp;D and modification in code.</p><p>Use following code for Rails(Edit functionality)<br
/> <span
style="color:#0000ff">rte1.html =&#8221;&lt;%=text_content.gsub(/&#8221;/, &#8220;&#8216;&#8221;).gsub(/\n/, &#8221;).gsub(/\r/, &#8221;) %&gt;&#8221;;</span></p><p>this will solve your problem.</p><p>Full code: (IF YOUR CODE NOT WORKS THAN USE MY FULL CODE)</p><p><span
style="color:#0000ff">&lt;script language=&#8221;JavaScript&#8221; type=&#8221;text/javascript&#8221;&gt;<br
/> &lt;!&#8211;<br
/> function submitForm() {<br
/> updateRTEs();<br
/> return false;<br
/> }<br
/> initRTE(&#8220;/cbrte/images/&#8221;, &#8220;/cbrte/&#8221;, &#8220;&#8221;, true);<br
/> //&#8211;&gt;<br
/> &lt;/script&gt;<br
/> &lt;noscript&gt;&lt;p&gt;&lt;b&gt;Javascript must be enabled to use this form.&lt;/b&gt;&lt;/p&gt;&lt;/noscript&gt;<br
/> &lt;script language=&#8221;JavaScript&#8221; type=&#8221;text/javascript&#8221;&gt;<br
/> &lt;!&#8211;<br
/> //build new richTextEditor<br
/> var rte1 = new richTextEditor(&#8216;text_content&#8217;);<br
/> rte1.html = &#8216;Write your thoughts here.&#8217;;<br
/> rte1.toggleSrc = true;<br
/> rte1.width = 500;<br
/> rte1.build();<br
/> //&#8211;&gt;<br
/> &lt;/script&gt;</span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/10/rich-text-editor-in-rails-application/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Rails if else statement</title><link>http://wordpressapi.com/2009/09/10/rails-if-else-statement/</link> <comments>http://wordpressapi.com/2009/09/10/rails-if-else-statement/#comments</comments> <pubDate>Thu, 10 Sep 2009 11:49:03 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[elsif]]></category> <category><![CDATA[if else]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=213</guid> <description><![CDATA[Here i am going to give some example of conditional statements in Rails. Normal IF ELSE &#60;% if user %&#62; &#60;%= user.name %&#62; &#60;% else %&#62; Anonymous &#60;% end %&#62; Normal code for ELSIF if var == 10 print “Variable is 10″ elsif var == “20″ print “Variable is 20″ else print “Variable is something.....]]></description> <content:encoded><![CDATA[<p>Here i am going to give some example of conditional statements in Rails.<br
/> Normal IF ELSE<br
/> <span
style="color:#0000ff">&lt;% if user %&gt;<br
/> &lt;%= user.name %&gt;<br
/> &lt;% else %&gt;<br
/> Anonymous<br
/> &lt;% end %&gt;</span></p><p>Normal code for ELSIF<br
/> <span
style="color:#0000ff">if var == 10<br
/> print “Variable is 10″<br
/> elsif var == “20″<br
/> print “Variable is 20″<br
/> else<br
/> print “Variable is something else”<br
/> end</span></p><p>Technic:<br
/> How to Put this in one line:<br
/> <span
style="color:#0000ff">&lt;%= user.name if user %&gt;</span> This is the simplest way.</p><p>How to use IF and ELSE statement in one line:<br
/> <span
style="color:#0000ff">&lt;%= user ? user.name : &#8220;Anonymous&#8221; %&gt;</span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/10/rails-if-else-statement/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Removing a versioned file/directory or fetch svn project without svn files and without deleting it</title><link>http://wordpressapi.com/2009/09/10/removing-a-versioned-filedirectory-or-fetch-svn-project-without-svn-files-and-without-deleting-it/</link> <comments>http://wordpressapi.com/2009/09/10/removing-a-versioned-filedirectory-or-fetch-svn-project-without-svn-files-and-without-deleting-it/#comments</comments> <pubDate>Thu, 10 Sep 2009 11:37:33 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[fedora]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[subversion]]></category> <category><![CDATA[svn]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=211</guid> <description><![CDATA[I worked with any technologies and languages. Many times we need some folder or codebase for your new project. So we need to copy old project code or folder in our new project. In rails we need many plugins for our project. Some times few plugins are not getting installed in our project. Few days.....]]></description> <content:encoded><![CDATA[<p>I worked with any technologies and languages. Many times we need some folder or codebase for your new project.<br
/> So we need to copy old project code or folder in our new project. In rails we need many plugins for our project. Some times few plugins are not getting installed in our project.</p><p>Few days back i tried to install acts_as_solr plugin in my project. I got an error. So i coppied acts_as_solr plugin from my old project and pasted in new project.</p><p>When i tried to SVN commit the files in the new project. That files started commiting to Old project.<br
/> So i need to remove all .svn folders form all the subfolders. Than only i can add all the folder to new project.</p><p><em>I google around for solution. I found many ways:</em></p><ul><li> Remove the all .svn folder from all subfolder.</li><li> Through linux command find all .svn file and delete. (but i think this harmful)</li><li> SVN export &#8211; command</li></ul><p><strong>SVN export</strong> is the very simple and reliable way to fetch project out of svn.<br
/> In windows, using <strong>svn export</strong> is very easy.</p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/10/removing-a-versioned-filedirectory-or-fetch-svn-project-without-svn-files-and-without-deleting-it/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Paperclip with Rails for image manipulation</title><link>http://wordpressapi.com/2009/09/10/paperclip-with-rails-for-image-manipulation/</link> <comments>http://wordpressapi.com/2009/09/10/paperclip-with-rails-for-image-manipulation/#comments</comments> <pubDate>Thu, 10 Sep 2009 11:11:42 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Open source]]></category> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[attachment_fu]]></category> <category><![CDATA[file upload]]></category> <category><![CDATA[image]]></category> <category><![CDATA[peperclip]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[upload]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=207</guid> <description><![CDATA[I used the spree e-Commerce CMS for checking or R&#38;D of Spree code. Spree is the really nice and basic tool for e-Commerce CMS. When i was going through Spree i got to know about paperclip plugin which is used for image manipulation. Earlier i used &#8220;attachment_fu&#8221; for image manipulation and file uploading in rails.....]]></description> <content:encoded><![CDATA[<p>I used the spree e-Commerce CMS for checking or R&amp;D of Spree code. Spree is the really nice and basic tool for e-Commerce CMS.</p><p>When i was going through Spree i got to know about paperclip plugin which is used for image manipulation. Earlier i used &#8220;<cite><strong>attachment_fu&#8221; </strong></cite>for image manipulation and file uploading in rails projects.</p><p>How to use &#8220;<strong>Paperclip</strong>&#8216;</p><p>First install perperclip plugin to your project.</p><p>Windows and Linux user can use my code. (I used this in WindowsXP and Fedora 9)</p><p><span
style="color:#0000ff">#ruby script /plugin install <a
href="https://svn.thoughtbot.com/plugins/paperclip/trunk/">https://svn.thoughtbot.com/plugins/paperclip/trunk/</a></span></p><p><span
style="color:#0000ff"><span
style="color:#000000">through this command perperclip get installed in your project folder.</span></span></p><p><span
style="color:#0000ff"><span
style="color:#000000">Many time you need photo upload functionality for customer</span></span></p><p><span
style="color:#0000ff"><span
style="color:#000000">Here i used Customer contoller and Customer model for this lession</span></span></p><p>First run following command</p><p><span
style="color:#000080">#ruby script/generate paperclip ModelName FieldName</span></p><p><span
style="color:#000080"><span
style="color:#000000">In my case command is:</span></span></p><p><span
style="color:#0000ff">#ruby script/generate paperclip Customer customer_pic</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">One migration file will be created through this command. Run that migration. </span><br
/> </span></p><p><span
style="color:#0000ff"><span
style="color:#000000">In Customer model file paste this code:<br
/> </span></span></p><p><span
style="color:#0000ff"><code>class Customer &lt; ActiveRecord::Base<br
/> # Paperclip<br
/> has_attached_file :customer_pic,<br
/> :styles =&gt; {<br
/> :thumb=&gt; "100x100#",<br
/> :small  =&gt; "150x150&gt;" }<br
/> end</code></span></p><p>Using this command you will save three pic(photo) in your system folder.</p><p>Default upload url of peperclip is (RAILS_ROOT/public/system/&#8230;)</p><p>You can use following lines in your model file. (copy &amp; paste this code under styles code)</p><p><span
style="color:#0000ff">:url =&gt; &#8220;/uploads/:class/:attachment/:id/:style_:basename.:extension&#8221;,<br
/> :path =&gt; &#8220;:rails_root/public/uploads/:class/:attachment/:id/:style_:basename.:extension&#8221;</span></p><p>I added uploads folder front on :class. That is optional you can remove also.</p><p><span
style="color:#0000ff"><span
style="color:#000000">If you are already having forms for customer and if you want to add that to form. Just use this code in your form tag.</span></span></p><p><span
style="color:#0000ff"><code>:html =&gt; { :multipart =&gt; true</code></span></p><p><span
style="color:#0000ff"><code><span
style="color:#0000ff">and in from </span></code></span><code><span
style="color:#0000ff">&lt;%= f.file_field :customer_pic%&gt;</span></code></p><p><code><span
style="color:#0000ff"><span
style="color:#000000">That sit. you need to add or use following code in View</span></span></code></p><p><code><span
style="color:#0000ff"><span
style="color:#000000"> </span></span></code><span
style="color:#0000ff"><code>&lt;%= image_tag @user.customer_pic.url %&gt;</code></span></p><p><span
style="color:#0000ff"><code>&lt;%= image_tag @user.customer_pic.url(:thumb) %&gt;</code></span></p><p><span
style="color:#0000ff"> </span></p><p><span
style="color:#0000ff"> </span></p><p><strong>Paperclip Validations</strong></p><p><span
style="color:#0000ff"><code><span
style="color:#000000">Here i giving some validation for Paperclip. You need to just copy &amp; paste in to your model where you want to use image upload.</span></code></span></p><p><span
style="color:#0000ff"><code><span
style="color:#000000"> </span></code></span></p><p><span
style="color:#0000ff"><code><span
style="color:#000000"> </span></code></span></p><p><span
style="color:#0000ff"><code>validates_attachment_content_type :avatar, :content_type =&gt; 'image/jpeg'</code></span></p><pre><span style="color:#0000ff"><code>validates_attachment_presence :avatar
</code></span></pre><p><span
style="color:#0000ff"><code><span
style="color:#000000">I found this plugin is very usefull for Me. It really saves lots of time.</span></code></span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/10/paperclip-with-rails-for-image-manipulation/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Basic of Rails routing -rails routes basic hack</title><link>http://wordpressapi.com/2009/09/08/basic-of-rails-routing-rails-routes-basic-hack/</link> <comments>http://wordpressapi.com/2009/09/08/basic-of-rails-routing-rails-routes-basic-hack/#comments</comments> <pubDate>Tue, 08 Sep 2009 14:25:57 +0000</pubDate> <dc:creator>Sony</dc:creator> <category><![CDATA[Ruby on Rails]]></category> <category><![CDATA[basic rails]]></category> <category><![CDATA[hack]]></category> <category><![CDATA[MySql]]></category> <category><![CDATA[Rails]]></category> <category><![CDATA[route]]></category><guid
isPermaLink="false">http://purab.wordpress.com/?p=203</guid> <description><![CDATA[Here I am going to focus on only basic routing technic of Rails. If you are new in rails. Just wanted to remind you. First go to Rails project&#8217;s &#8220;public&#8221; folder and delete or rename the index.html file. If index.html file is there then default routing will not run. If you want Users controller&#8217;s index.....]]></description> <content:encoded><![CDATA[<p>Here I am going to focus on only basic routing technic of Rails.</p><p>If you are new in rails. Just wanted to remind you.</p><p>First go to Rails project&#8217;s &#8220;public&#8221; folder and delete or rename the index.html file. If index.html file is there then default routing will not run.</p><p>If you want Users controller&#8217;s index page as a home page of site then go for this code in routes.rb file.</p><p><span
style="color:#0000ff">map.connect &#8221;, { :controller =&gt; &#8216;users&#8217;, :action =&gt; &#8216;index&#8217; }</span></p><p><span
style="color:#0000ff"><span
style="color:#000000">In view you can use link for home page and logo of site(basic hack)</span></span></p><p><span
style="color:#0000ff">&lt;%= link_to(&#8220;HOME&#8221;,{:controller=&gt;&#8217;/'}) %&gt;</span></p><p><span
style="color:#0000ff"><br
/> </span></p> ]]></content:encoded> <wfw:commentRss>http://wordpressapi.com/2009/09/08/basic-of-rails-routing-rails-routes-basic-hack/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 137/221 queries in 0.753 seconds using disk

Served from: wordpressapi.com @ 2010-09-09 21:16:52 -->