<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<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/"
	>

<channel>
	<title>Ruby on Rails</title>
	<link>http://satishchauhan.com</link>
	<description>{satish => RubyOnRails.new}</description>
	<pubDate>Thu, 01 Jan 2009 12:09:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>Rounded Corners Using Pure CSS Without Images And Javascript</title>
		<link>http://satishchauhan.com/2009/01/01/rounded-corners-using-pure-css-without-images-and-javascript/</link>
		<comments>http://satishchauhan.com/2009/01/01/rounded-corners-using-pure-css-without-images-and-javascript/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 12:02:31 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2009/01/01/rounded-corners-using-pure-css-without-images-and-javascript/</guid>
		<description><![CDATA[
* {margin: 0; padding: 0}
.roundedCorner { font-family: verdana, arial; width: 500px;	margin: 10px auto; text-align:center; }
.roundedCorner p { font-size:18px; padding:10px;}
.text {	border: 1px solid #B0BCC2; border-width: 0 1px;	padding: 5px 10px;}
.b1, .b2, .b3, .b4, .b5,.b1 b,.b2 b, .b3 b, .b4 b, .b5 b{
  height: 1px;	font-size: 1px;	overflow: hidden;	border-style: solid;	border-width: 0 1px;	display: block;
}
.b1 { margin: 0 2px; background: #EBEEF0;	border: [...]]]></description>
			<content:encoded><![CDATA[<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;"><br />
* {margin: 0; padding: 0}<br />
.roundedCorner { font-family: verdana, arial; width: 500px;	margin: 10px auto; text-align:center; }<br />
.roundedCorner p { font-size:18px; padding:10px;}<br />
.text {	border: 1px solid #B0BCC2; border-width: 0 1px;	padding: 5px 10px;}<br />
.b1, .b2, .b3, .b4, .b5,.b1 b,.b2 b, .b3 b, .b4 b, .b5 b{<br />
  height: 1px;	font-size: 1px;	overflow: hidden;	border-style: solid;	border-width: 0 1px;	display: block;<br />
}<br />
.b1 { margin: 0 2px; background: #EBEEF0;	border: none;}<br />
.b1 b { margin: 0 1px; background: #B8C3C8; border-color: #CBD3D7;}<br />
.b2 {margin: 0 1px;	border-color: #D6DCDF;}<br />
.b2 b {border-color: #B8C3C8;}<br />
.b3 {border-color: #EBEEEF;}<br />
.b3 b {border-color: #BCC6CB;}<br />
.b4 {border-color: #CAD2D6;}<br />
.b4 b {border-color: #E5E9EB;}<br />
.b5 {border-color: #B5C0C6;}<br />
.b5 b {border-color: #FAFBFB;}<br />
</textarea></p>
<p>The above code will generate the following ouput</p>
<style>
* {margin: 0; padding: 0}
.roundedCorner { font-family: verdana, arial; width: 500px;	margin: 10px auto; text-align:center; }
.roundedCorner p { font-size:18px; padding:10px;}
.text {	border: 1px solid #B0BCC2; border-width: 0 1px;	padding: 5px 10px;}
.b1, .b2, .b3, .b4, .b5,.b1 b,.b2 b, .b3 b, .b4 b, .b5 b{
  height: 1px;	font-size: 1px;	overflow: hidden;	border-style: solid;	border-width: 0 1px;	display: block;
}
.b1 { margin: 0 2px; background: #EBEEF0;	border: none;}
.b1 b { margin: 0 1px; background: #B8C3C8; border-color: #CBD3D7;}
.b2 {margin: 0 1px;	border-color: #D6DCDF;}
.b2 b {border-color: #B8C3C8;}
.b3 {border-color: #EBEEEF;}
.b3 b {border-color: #BCC6CB;}
.b4 {border-color: #CAD2D6;}
.b4 b {border-color: #E5E9EB;}
.b5 {border-color: #B5C0C6;}
.b5 b {border-color: #FAFBFB;}
</style>
<div class="roundedCorner">
<div class="b1"><b></b></div>
<div class="b2"><b></b></div>
<div class="b3"><b></b></div>
<div class="b4"><b></b></div>
<div class="b5"><b></b></div>
<div class="text">
<h2>Example One</h2>
<p>Rounded Corners Without Any Css and Javascript</p>
</p></div>
<div class="b5"><b></b></div>
<div class="b4"><b></b></div>
<div class="b3"><b></b></div>
<div class="b2"><b></b></div>
<div class="b1"><b></b></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2009/01/01/rounded-corners-using-pure-css-without-images-and-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dynamic Scope Methods in Edge Rails</title>
		<link>http://satishchauhan.com/2008/12/30/dynamic-scope-methods-in-edge-rails/</link>
		<comments>http://satishchauhan.com/2008/12/30/dynamic-scope-methods-in-edge-rails/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 21:56:58 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2008/12/31/dynamic-scope-methods-in-edge-rails/</guid>
		<description><![CDATA[We perform simple queries using dynamic finder and for commonly used query logic we use named scope.

User.find_all_by_user_name_and_password(user_name, password)
# SELECT * FROM users WHERE user_name = user_name AND password = password
named_scope :active, :conditions =&#62; { :status =&#62; true}
User.active
# SELECT * FROM users WHERE status=1

but we can’t chain query conditions when using these dynamic finders.
With the addition [...]]]></description>
			<content:encoded><![CDATA[<p>We perform simple queries using dynamic finder and for commonly used query logic we use named scope.<br />
<textarea class="ruby" rows="10" cols="50" name="code" style="display: none;"><br />
User.find_all_by_user_name_and_password(user_name, password)<br />
# SELECT * FROM users WHERE user_name = user_name AND password = password</p>
<p>named_scope :active, :conditions =&gt; { :status =&gt; true}</p>
<p>User.active<br />
# SELECT * FROM users WHERE status=1<br />
</textarea></p>
<p>but we can’t chain query conditions when using these dynamic finders.</p>
<p>With the addition of dynamic scopes, we can now have a way to both quickly specify query logic and chain further conditions.</p>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;"><br />
User.scoped_by_user_name_and_password(user_name, password).find(:all, :limit =&gt; 3)<br />
#=&gt; SELECT * FROM users WHERE user_name = user_name AND password = password LIMIT 3</p>
<p>User.scoped_by_user_name(user_name).scoped_by_password(password)<br />
#=&gt; SELECT * FROM users WHERE user_name = user_name AND password = password</p>
<p>User.scoped_by_user_name(user_name).scoped_by_password(password).scoped_by_status(true)<br />
#=&gt; SELECT * FROM users WHERE user_name = user_name AND password = password AND status=1<br />
</textarea><br />
We can now use class methods like scoped_by_user_name(user_name) and scoped_by_user_name_and_password(user_name, password) that will use the scoped method with attributes you supply.</p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2008/12/30/dynamic-scope-methods-in-edge-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Merb gets merged into Rails 3</title>
		<link>http://satishchauhan.com/2008/12/28/merb-gets-merged-into-rails-3/</link>
		<comments>http://satishchauhan.com/2008/12/28/merb-gets-merged-into-rails-3/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 21:07:15 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2008/12/31/merb-gets-merged-into-rails-3/</guid>
		<description><![CDATA[Ruby on Rails and Merb team decided to  merge both of the frameworks into a singular web framework in Rails 3. The two frameworks have much in common and share code in a variety of places.
Please click here to find the detailed post by DHH.
]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails and Merb team decided to  merge both of the frameworks into a singular web framework in Rails 3. The two frameworks have much in common and share code in a variety of places.</p>
<p>Please <a href="http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3">click here</a> to find the detailed post by DHH.</p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2008/12/28/merb-gets-merged-into-rails-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>First Ruby Fun Day : A Ruby And Ruby On Rails Event In India</title>
		<link>http://satishchauhan.com/2008/11/19/first-fun-day-a-ruby-and-ruby-on-rails-event-in-india/</link>
		<comments>http://satishchauhan.com/2008/11/19/first-fun-day-a-ruby-and-ruby-on-rails-event-in-india/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 20:35:03 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2008/11/19/first-fun-day-a-ruby-and-ruby-on-rails-event-in-india/</guid>
		<description><![CDATA[Geekeerie organising a full day ruby and ruby on rails event scheduled on 22, Nov 2008 at Impetus Technologies, D-40, Sector 59,NOIDA,UP,India            Noida, India.
And not just that, RubyFunDay comes with free goooodies like lunch and Ruby p T-Shirt.
So as you have signed up already [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://satishchauhan.com/wp-admin/" target="_blank">Geekeerie</a> organising a full day ruby and ruby on rails event scheduled on 22, Nov 2008 at <a href="http://www.impetus.com/" target="_blank">Impetus Technologies</a>, D-40, Sector 59,NOIDA,UP,India            Noida, India.</p>
<p>And not just that, RubyFunDay comes with free goooodies like lunch and Ruby p T-Shirt.</p>
<p>So as you have signed up already for the event, please provide us your T-Shirt size here <a href="http://spreadsheets.google.com/viewform?key=p2AxAft0ZpLVXLO-mLbpPFw" target="_blank">http://spreadsheets.google.<wbr></wbr>com/viewform?key=<wbr></wbr>p2AxAft0ZpLVXLO-mLbpPFw</a></p>
<p><a href="http://rubyonrails.in/events/3"><img src="http://assets1.rubyonrails.in/system/event/event_logo/3/medium/350x350Banner.png?1225773969" width="150" height="150" /></a></p>
<p>For event details and participation confirmation: visit <a href="http://www.rubyonrails.in/events/3" target="_blank"> http://rubyonrails.in/events/3 </a></p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2008/11/19/first-fun-day-a-ruby-and-ruby-on-rails-event-in-india/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to load selective fixtures to db in rails</title>
		<link>http://satishchauhan.com/2007/08/30/how-to-load-selective-fixtures-to-db-in-rails/</link>
		<comments>http://satishchauhan.com/2007/08/30/how-to-load-selective-fixtures-to-db-in-rails/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 12:41:21 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[fixture]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2007/08/30/how-to-load-selective-fixtures-to-db-in-rails/</guid>
		<description><![CDATA[Al of you know how to load fixture to db
rake db:fixtures:load 
To load a subset of your fixtures to your projects db
rake db:fixtures:load FIXTURES=users,stores
]]></description>
			<content:encoded><![CDATA[<p class="snap_preview">Al of you know how to load fixture to db</p>
<pre><span class="code">rake db:fixtures:load </span></pre>
<p>To load a subset of your fixtures to your projects db</p>
<pre><span class="code">rake db:fixtures:load FIXTURES=users,stores</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2007/08/30/how-to-load-selective-fixtures-to-db-in-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Star rating in ruby on rails</title>
		<link>http://satishchauhan.com/2007/08/24/star-rating-in-ruby-on-rails/</link>
		<comments>http://satishchauhan.com/2007/08/24/star-rating-in-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 05:22:15 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[rating]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2007/08/24/star-rating-in-ruby-on-rails/</guid>
		<description><![CDATA[ Recently I needed to implement star rating system for one of my project I am working on.
If you are not familiar with a star rating system, its simply a method of voting using (usually) 5 stars in a row, which will change colour as you hover over them indicating the level at which to [...]]]></description>
			<content:encoded><![CDATA[<p class="justification"> Recently I needed to implement star rating system for one of my project I am working on.</p>
<p class="justification">If you are not familiar with a star rating system, its simply a method of voting using (usually) 5 stars in a row, which will change colour as you hover over them indicating the level at which to rate something. You may think a simple rollover would accomplish this but difficulty arises because as you rollover each star it should stay highlighted while you light up the next one and so on until the end of the row of stars.</p>
<p class="justification">If this doesnt make much sense to you then take a look at what we are going to achieve in this article. (I will leave the server-side coding to someone more knowledgeable and we will just concentrate on the visual aspects of making this effect happen. )</p>
<p class="justification">As you can see from the demo the stars stay hovered as you rollover each one. However, as mentioned earlier, the complicated part is that as each star is hovered it should stay alight while the next one is hovered so that if you start at the left side then 1,2,3,4 and 5 stars will be alight as you traverse the row. Usually a rollover will only be active on the anchor that the pointer is currently over making previous anchors lose their focus and thus their hover effect disappear.</p>
<p class="justification">&nbsp;</p>
<p><strong>Install the acts_as_rateable plugin. </strong></p>
<p>Run the following from the root of your Rails app to install the plugin.</p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">script/plugin install http://juixe.com/svn/acts_as_rateable</textarea><br />
or<br />
http://rubyforge.org/projects/rateableplugin/</p>
<p><strong>Create the table(migration) to store rating into database</strong></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">class CreateRatings< ActiveRecord::Migration</p>
<p>  def self.up<br />
    create_table :ratings, :force => true do |t|<br />
      t.column :rating, :integer, :default => 0<br />
      t.column :created_at, :datetime, :null => false<br />
      t.column :rateable_type, :string, :limit => 15,<br />
      :default => &#8220;&#8221;, :null => false<br />
      t.column :rateable_id, :integer, :default => 0, :null => false<br />
      t.column :user_id, :integer, :default => 0, :null => false<br />
    end</p>
<p>    add_index :ratings, [&#8221;user_id&#8221;], :name => &#8220;fk_ratings_user&#8221;<br />
  end</p>
<p>  def self.down<br />
    drop_table :ratings<br />
  end</p>
<p>end</textarea></p>
<p><strong>Model</strong></p>
<p><strong>models rateable</strong></p>
<p>I was trying to add a rating system for the model Picture. Yours can obviously be whatever you like but from here on out I’ll be using Picture. So add acts_as_rateable to your model.</p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">class Picture < ActiveRecord::Base<br />
  acts_as_rateable<br />
  ...<br />
end</textarea></p>
<p><strong>Controller to handle the rating</strong></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">class RatingController < ApplicationController</p>
<p>  def rate<br />
    @picture = Picture.find(params[:id])<br />
    Rating.delete_all(["rateable_type = 'Picture' AND rateable_id = ? AND user_id = ?",<br />
      @picture.id, current_user.id])<br />
    @picture.add_rating Rating.new(:rating => params[:rating],<br />
      :user_id => current_user.id)<br />
  end</p>
<p>end</textarea></p>
<p><strong>Views</strong></p>
<p>Create the partial <em>/views/rating/_rating.rhtml</em></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;"><%= number_with_precision(picture.rating, 1) %>/5 Stars</p>
<ul class='star-rating'>
<li class='current-rating' style='width:<%= (picture.rating * 30).to_i -%>px;&#8217;><br />
          Currently <%= number_with_precision(picture.rating, 1) %>/5 Stars.
        </li>
<li>
        <%= link_to_remote( "1", {:url => { :controller => &#8220;rating&#8221;,<br />
            :action => &#8220;rate&#8221;, :id => picture.id, :rating => 1}},<br />
            :class => &#8216;one-star&#8217;, :name => &#8216;1 star out of 5&#8242;) %>
    </li>
<li>
        <%= link_to_remote( "2", {:url => { :controller => &#8220;rating&#8221;,<br />
            :action => &#8220;rate&#8221;, :id => picture.id, :rating => 2}},<br />
            :class => &#8216;two-stars&#8217;, :name => &#8216;2 stars out of 5&#8242;) %>
    </li>
<li>
        <%= link_to_remote( "3", {:url => { :controller => &#8220;rating&#8221;,<br />
            :action => &#8220;rate&#8221;, :id => picture.id, :rating => 3}},<br />
            :class => &#8216;three-stars&#8217;, :name => &#8216;3 stars out of 5&#8242;) %>
    </li>
<li>
        <%= link_to_remote( "4", {:url => { :controller => &#8220;rating&#8221;,<br />
            :action => &#8220;rate&#8221;, :id => picture.id, :rating => 4}},<br />
            :class => &#8216;four-stars&#8217;, :name => &#8216;4 stars out of 5&#8242;) %>
    </li>
<li>
        <%= link_to_remote( "5", {:url => { :controller => &#8220;rating&#8221;,<br />
            :action => &#8220;rate&#8221;, :id => picture.id, :rating => 5}},<br />
            :class => &#8216;five-stars&#8217;, :name => &#8216;5 stars out of 5&#8242;) %>
    </li>
</ul>
<p></textarea></p>
<p><strong>A little <span class="caps">RJS</span></strong></p>
<p>Create the file <em>/views/rating/rate.rjs</em></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">page.replace_html &#8220;star-ratings-block&#8221;, :partial => &#8216;rating/rating&#8217;, :locals => { :picture=> @picture }</textarea></p>
<p>This will replace the star ratings with the partial we created previously in order to reflect any rating changes made by the submission.</p>
<p>Render the partial in one of your views.</p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">
<div id="star-ratings-block">
    <%= render :partial => &#8220;rating/rating&#8221;, :locals => { :picture => @picture } %>
</div>
<p></textarea></p>
<p>This needs @picture(or whatver you’re going to be using) in order to function.</p>
<p>Remember to add the css and image</p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">/* styles for the star rater */<br />
.star-rating{<br />
list-style:none;<br />
margin: 0;<br />
padding:0;<br />
width: 150px;<br />
height: 30px;<br />
position: relative;<br />
background: url(/images/star_rating.gif) top left repeat-x;<br />
}<br />
.star-rating li{<br />
padding:0;<br />
margin:0;<br />
float: left;<br />
}<br />
.star-rating li a{<br />
display:block;<br />
width:30px;<br />
height: 30px;<br />
text-decoration: none;<br />
text-indent: -9000px;<br />
z-index: 20;<br />
position: absolute;<br />
padding: 0px;<br />
}<br />
.star-rating li a:hover{<br />
background: url(/images/star_rating.gif) left center;<br />
z-index: 2;<br />
left: 0px;<br />
border:none;<br />
}<br />
.star-rating a.one-star{<br />
left: 0px;<br />
}<br />
.star-rating a.one-star:hover{<br />
width:30px;<br />
}<br />
.star-rating a.two-stars{<br />
left:30px;<br />
}<br />
.star-rating a.two-stars:hover{<br />
width: 60px;<br />
}<br />
.star-rating a.three-stars{<br />
left: 60px;<br />
}<br />
.star-rating a.three-stars:hover{<br />
width: 90px;<br />
}<br />
.star-rating a.four-stars{<br />
left: 90px;<br />
}<br />
.star-rating a.four-stars:hover{<br />
width: 120px;<br />
}<br />
.star-rating a.five-stars{<br />
left: 120px;<br />
}<br />
.star-rating a.five-stars:hover{<br />
width: 150px;<br />
}<br />
.star-rating li.current-rating{<br />
background: url(/images/star_rating.gif) left bottom;<br />
position: absolute;<br />
height: 30px;<br />
display: block;<br />
text-indent: -9000px;<br />
z-index: 1;<br />
}</textarea></p>
<p><strong>Image for your CSS</strong></p>
<p><img src="http://satishchauhan.com/wp-includes/images/star_rating.gif" title="star_rating.gif" alt="star_rating.gif" height="90" width="30" /></p>
<pre></pre>
<p class="justification">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2007/08/24/star-rating-in-ruby-on-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Paginate With Ajax</title>
		<link>http://satishchauhan.com/2007/08/01/how-to-paginate-with-ajax/</link>
		<comments>http://satishchauhan.com/2007/08/01/how-to-paginate-with-ajax/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 14:53:50 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[ajax]]></category>

		<category><![CDATA[paginate]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/2007/08/01/how-to-paginate-with-ajax/</guid>
		<description><![CDATA[Pagination is a very common task in web application development. But sometimes we need to paginate something with ajax request. The interest to use Ajax for this is to provide a dynamic interface which doesn&#8217;t need to reload the entire page when next results(page) displayed. Ajax is really nicely integrated with Rails, and using it [...]]]></description>
			<content:encoded><![CDATA[<p>Pagination is a very common task in web application development. But sometimes we need to paginate something with ajax request. The interest to use Ajax for this is to provide a dynamic interface which doesn&#8217;t need to reload the entire page when next results(page) displayed. Ajax is really nicely integrated with Rails, and using it is very easier with this great framework.   To work with ajax requests your browser must be enabled to handled  java script requests. I knew two methods for that problem.</p>
<p><strong>First Method</strong></p>
<p><strong>Your Controller code</strong></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none">def ajax_pagination_links<br />
  @posts_pages, @posts= paginate :posts, :per_page => 3, :order => &#8220;id DESC&#8221;<br />
  respond_to do |format|<br />
    format.html {render :partial=>&#8221;posts&#8221;,:layout=>&#8221;application&#8221;}<br />
    format.js {render :update do |page|<br />
                page.replace_html &#8216;total_posts&#8217;, :partial=>&#8217;total_posts&#8217;<br />
                page.visual_effect :highlight, &#8220;total_posts&#8221;<br />
                end<br />
              }<br />
  end<br />
end</textarea></p>
<p><strong>Layout</strong></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none"> <%= javascript_include_tag :defaults %></textarea></p>
<p><strong>View</strong></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none"><br />
<table width="100%">
<tr>
<td>
<table  id="total_posts" >
        <%= render :partial=>&#8220;total_posts&#8221;%><br />
      </table>
</td>
</tr>
</table>
<p></textarea></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none"><% for post in @posts %></p>
<tr>
<td>
      <strong><%= truncate(h(post.title.capitalize!),50) -%></strong>
    </td>
</tr>
<tr>
<td>
      <strong><%= truncate(h(post.description.capitalize!),50) -%></strong>
    </td>
</tr>
<p>  <%end -%></p>
<tr>
<td>
      <span><br />
        <%= link_to_remote 'Previous page',{:url=>{:action=>ajax_pagination_links, :page => @posts_pages.current.previous },  if @posts_pages.current.previous -%>             </p>
<p>        <%= link_to_remote 'Next page', {:url=>{:action=>ajax_pagination_links, :page => @posts_pages.current.next} if @posts_pages.current.next -%><br />
      </span>
    </td>
</tr>
<p></textarea></p>
<p><strong>Second Method</strong></p>
<p>Put this code in a helper somewhere</p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none">def ajax_pagination_links(paginator, options={})<br />
    options.merge!(ActionView::Helpers::PaginationHelper::DEFAULT_OPTIONS) {|key, old, new| old}<br />
    window_pages = paginator.current.window(options[:window_size]).pages<br />
    return if window_pages.length <= 1 unless<br />
    options[:link_to_current_page]</p>
<p>    first, last = paginator.first, paginator.last</p>
<p>    returning html = '' do<br />
    if options[:always_show_anchors] and not window_pages[0].first?<br />
      html << link_to_remote(first.number, :update => options[:update], :url => { options[:name] => first }.update(options[:params] ))<br />
      html << ' ... ' if window_pages[0].number - first.number > 1<br />
      html << ' '<br />
    end</p>
<p>    window_pages.each do |page|<br />
      if paginator.current == page &#038;&#038; !options[:link_to_current_page]<br />
        html << page.number.to_s<br />
      else<br />
        html << link_to_remote(page.number, :update => options[:update], :url => { options[:name] => page }.update(options[:params] ))<br />
      end<br />
      html << ' '<br />
      end</p>
<p>      if options[:always_show_anchors] &#038;&#038; !window_pages.last.last?<br />
        html << ' ... ' if last.number - window_pages[-1].number > 1<br />
        html << link_to_remote(paginator.last.number, :update => options[:update], :url => { options[:name] => last }.update( options[:params]))<br />
      end<br />
    end<br />
  end </textarea></p>
<p>and use following code for creating links<br />
<strong>View</strong></p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none"><%= ajax_pagination_links @posts_pages, {:params => {:posts => @posts} } %> </textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2007/08/01/how-to-paginate-with-ajax/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to use SyntaxHighlighter</title>
		<link>http://satishchauhan.com/2007/07/23/how-to-use-syntaxhighlighter/</link>
		<comments>http://satishchauhan.com/2007/07/23/how-to-use-syntaxhighlighter/#comments</comments>
		<pubDate>Mon, 23 Jul 2007 13:23:20 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[SyntaxHighlighter]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/?p=13</guid>
		<description><![CDATA[ SyntaxHighlighter:
SyntaxHighlighter is a source code syntax highlighting plugin to help a developer/coder to post code snippets online with ease and and without having to worry about applying format. It is a free JavaScript tool for source code Syntex highlighting , It doesn&#8217;t care what you have on your server.
The idea behind SyntaxHighlighter is to [...]]]></description>
			<content:encoded><![CDATA[<p><strong> SyntaxHighlighter:</strong></p>
<p>SyntaxHighlighter is a source code syntax highlighting plugin to help a developer/coder to post code snippets online with ease and and without having to worry about applying format. It is a free JavaScript tool for source code Syntex highlighting , It doesn&#8217;t care what you have on your server.</p>
<p>The idea behind SyntaxHighlighter is to allow insertion of colored code snippets on a web page without relying on any server side scripts.</p>
<p>WP-dp.SyntaxHighlighter supported languages:</p>
<ul>
<li>C#</li>
<li>CSS</li>
<li>C++</li>
<li>VB &amp; VB.NET</li>
<li>Delphi, Pascal</li>
<li>Java</li>
<li>JavaScript</li>
<li>PHP</li>
<li>Python</li>
<li>Ruby</li>
<li>SQL</li>
<li>XML, HTML, XSLT and any other XML style code</li>
</ul>
<p><a href="http://syntaxhighlighter.googlecode.com/files/SyntaxHighlighter_1.5.0.zip">Click Here to download <strong> SyntaxHighlighter</strong> </a></p>
<p>http://syntaxhighlighter.googlecode.com/files/SyntaxHighlighter_1.5.0.zip</p>
<p><strong>How to use SyntaxHighlighter</strong></p>
<p>Place your code on the page and surround it with <tt>&lt;pre&gt;</tt> tag. Set <tt>name</tt>  attribute to <tt>code</tt> and <tt>class</tt> attribute to one of the language aliases you wish to use.</p>
<p>&lt;div <span class="nodeLabelBox repTarget"><span class="nodeAttr editGroup"><span class="nodeName editable">class</span>=&#8221;<span class="nodeValue editable">dp-highlighter</span>&#8220;</span><span class="nodeBracket editable insertBefore"></span></span>&gt; &lt;/div&gt;</p>
<p>&lt;pre name=&#8221;code&#8221; class=&#8221;ruby&#8221; <span class="nodeLabelBox repTarget"><span class="nodeAttr editGroup"></span><span class="nodeAttr editGroup"> <span collapsed="false" class="nodeName editable">style</span>=&#8221;<span class="nodeValue editable">display: none;</span>&#8220;</span></span>&gt;<br />
&#8230; some code here &#8230;<br />
&lt;/pre&gt;</p>
<p>An alternative to <tt>&lt;pre&gt;</tt> is to use <tt>&lt;textarea&gt;</tt> tag.</p>
<p>&lt;textarea name=&#8221;code&#8221; class=&#8221;ruby&#8221;&gt;<br />
&#8230; some code here &#8230;<br />
&lt;/textarea&gt;</p>
<p>And You will get an output like</p>
<div class="dp-highlighter"></div>
<p><textarea name="code" class="ruby" cols="50" rows="10"  style="display: none;">def create<br />
    if request.post?<br />
      @customer=CustomerInformation.new(params[:customer])<br />
      if @customer.save<br />
        Mailer.deliver_new_registration(@customer)<br />
        render :partial=> &#8216;thank_you&#8217;, :layout=>&#8217;application&#8217;<br />
      end<br />
    end<br />
  end </textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2007/07/23/how-to-use-syntaxhighlighter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to import CSV file in rails</title>
		<link>http://satishchauhan.com/2007/07/18/how-to-import-csv-file-in-rails/</link>
		<comments>http://satishchauhan.com/2007/07/18/how-to-import-csv-file-in-rails/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 12:47:16 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[CSV]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/?p=10</guid>
		<description><![CDATA[How to import CSV file in rails?
The CSV text-file format is a common choice for both import and export when performing data migrations. What if you want to import CSV files within a Rails application?
Here is the code that allow you to upload CSV data onto the MySQL database from the web interface
This code save [...]]]></description>
			<content:encoded><![CDATA[<p>How to import CSV file in rails?</p>
<p>The <span class="caps">CSV</span> text-file format is a common choice for both import and export when performing data migrations. What if you want to import <span class="caps">CSV</span> files within a Rails application?</p>
<p>Here is the code that <font size="1"><font size="2">allow you to upload CSV data onto the MySQL database from the web interface</font></font><br />
This code save data direct to database without saving it to temp file</p>
<p><strong>Controller: </strong></p>
<div class="dp-highlighter"></div>
<p><textarea name="code" class="ruby" cols="60" rows="10" style="display:none;"><br />
require ‘csv’</p>
<p>   def csv_import<br />
     @parsed_file=CSV::Reader.parse(params[:dump][:file])<br />
     n=0<br />
     @parsed_file.each  do |row|<br />
     c=CustomerInformation.new<br />
     c.job_title=row[1]<br />
     c.first_name=row[2]<br />
     c.last_name=row[3]<br />
     if c.save<br />
        n=n+1<br />
        GC.start if n%50==0<br />
     end<br />
     flash.now[:message]=”CSV Import Successful,  #{n} new records added to data base&#8221;<br />
   end</p>
<p></textarea><br />
<strong>View:</strong><br />
your view will look like</p>
<div class="dp-highlighter"></div>
<p><textarea name="code" class="ruby" cols="60" rows="10" style="display:none;"><br />
<% form_for :dump, :url=>{:controller=>”customer_informations”, :action=>&#8221;csv_import&#8221;}, :html => { :multipart => true } do |f| -%></p>
<table>
<tr>
<td>
        <label for="dump_file"><br />
          Select a CSV File :<br />
        </label>
      </td>
<td >
       <%= f.file_field :file -%>
     </td>
</tr>
<tr>
<td colspan='2'>
        <%= submit_tag 'Submit' -%>
      </td>
</tr>
</table>
<p><% end -%><br />
</textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2007/07/18/how-to-import-csv-file-in-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Verify Email address Format</title>
		<link>http://satishchauhan.com/2007/07/03/varify-email-address-format/</link>
		<comments>http://satishchauhan.com/2007/07/03/varify-email-address-format/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 11:07:02 +0000</pubDate>
		<dc:creator>Satish Chauhan</dc:creator>
		
		<category><![CDATA[Regexp]]></category>

		<category><![CDATA[ror]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://satishchauhan.com/?p=9</guid>
		<description><![CDATA[
Useful expressions for email address validation
Matches a limited version of the RFC 2822 addr-spec form.

/\A(?:[\w\!\#\$\%\&#038;\’\*\+\-\/\=\?\^\`\{\&#124;\}\~]+\.)*[\w\!\#\$\%\&#038;\’\*\+\-\/\=\?\^\`\{\&#124;\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)&#124;(?:\[(?:(?:[01]?\d{1,2}&#124;2[0-4]\d&#124;25[0-5])\.){3}(?:[01]?\d{1,2}&#124;2[0-4]\d&#124;25[0-5])\]))\Z/i

satish chauhan&#8217;s blog
]]></description>
			<content:encoded><![CDATA[<h3></h3>
<p>Useful expressions for email address validation</p>
<p>Matches a limited version of the RFC 2822 addr-spec form.</p>
<div class="dp-highlighter"></div>
<p><textarea class="ruby" rows="10" cols="50" name="code" style="display: none;">/\A(?:[\w\!\#\$\%\&#038;\’\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&#038;\’\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))\Z/i<br />
</textarea></p>
<p><a href="http://satishchauhan.blogspot.com">satish chauhan&#8217;s blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://satishchauhan.com/2007/07/03/varify-email-address-format/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
