<?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>Dhaval Parikh &#187; ruby on rails</title>
	<atom:link href="http://blog.dhavalparikh.co.in/tag/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dhavalparikh.co.in</link>
	<description>Ruby on Rails, Stock Markets, Technology news and info - Its all about my passion</description>
	<lastBuildDate>Wed, 25 Jan 2012 07:06:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Step by Step Twitter OAuth Integration with Rails</title>
		<link>http://blog.dhavalparikh.co.in/2009/06/step-by-step-twitter-oauth-integration-with-rails/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/06/step-by-step-twitter-oauth-integration-with-rails/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 03:14:36 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[OAuth + twitter + rails]]></category>
		<category><![CDATA[OAuth integration with rails]]></category>
		<category><![CDATA[rails OAuth and Twitter]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/?p=231</guid>
		<description><![CDATA[There are many articles posted under this topic but none of them have all information or a Step by Step guide of how to integrate OAuth for use with Twitter Apps and Rails. So thought of posting one here. Here are few steps which you should follow. The code below is same as provided by [...]]]></description>
			<content:encoded><![CDATA[<p class="claimcode">There are many articles posted under this topic but none of them have all information or a Step by Step guide of how to integrate OAuth for use with Twitter Apps and Rails.</p>
<p>So thought of posting one here. Here are few steps which you should follow. The code below is same as provided by the twitter wiki but i have made couple of changes and organized it to make it simple to understand</p>
<p>Step 1 : = You need to get your consumer key and consumer secret # from the twitter OAuth site under this link twitteroauth.</p>
<p>Step 2 := Install OAuth Gem with &#8220;gem install oauth&#8221; command on ur terminal</p>
<p>Step 3 := Generate a Scaffold using the following command and then migrate the table called &#8220;users&#8221; to ur database</p>
<p>ruby script/generate scaffold user screen_name:string token:string secret:string</p>
<p>rake db:migrate</p>
<p>Step 4 := Add the following code to your User Controller. Replace the key and secret code with yours <img src='http://blog.dhavalparikh.co.in/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>def self.consumer</p>
<p># The readkey and readsecret below are the values you get during registration</p>
<p>OAuth::Consumer.new(&#8220;OmwO7wsjtYHjquu6bd6C4w&#8221;, &#8220;j1kZ6yzsqChkeQtToErUx2LnPQMsSPkXMkiy4F82sPA&#8221;,{ :site=&gt;&#8221;http://twitter.com&#8221; })</p>
<p>end</p>
<p>def create</p>
<p>@request_token = UsersController.consumer.get_request_token</p>
<p>session[:request_token] = @request_token.token</p>
<p>session[:request_token_secret] = @request_token.secret</p>
<p># Send to twitter.com to authorize</p>
<p>redirect_to @request_token.authorize_url</p>
<p>return</p>
<p>end</p>
<p>Now this is an important part where you need to set the call back url Which u will define while you register your app at twitter OAuth site. Again add this to the UserController</p>
<p>def callback<br />
@request_token = OAuth::RequestToken.new(UsersController.consumer,<br />
session[:request_token],<br />
session[:request_token_secret])<br />
# Exchange the request token for an access token.<br />
@access_token = @request_token.get_access_token<br />
@response = UsersController.consumer.request(:get, &#8216;/account/verify_credentials.json&#8217;,<br />
@access_token, { :scheme =&gt; :query_string })<br />
case @response<br />
when Net::HTTPSuccess<br />
user_info = JSON.parse(@response.body)<br />
unless user_info['screen_name']<br />
flash[:notice] = &#8220;Authentication failed&#8221;<br />
redirect_to :action =&gt; :index<br />
return<br />
end</p>
<p># We have an authorized user, save the information to the database.<br />
@user = User.new({ :screen_name =&gt; user_info['screen_name'],:token =&gt; @access_token.token,:secret =&gt; @access_token.secret })<br />
@user.save!<br />
# Redirect to the show page<br />
redirect_to(@user)<br />
else<br />
RAILS_DEFAULT_LOGGER.error &#8220;Failed to get user info via OAuth&#8221;<br />
# The user might have rejected this application. Or there was some other error during the request.<br />
flash[:notice] = &#8220;Authentication failed&#8221;<br />
redirect_to :action =&gt; :index<br />
return<br />
end<br />
end<br />
end</p>
<p>As you can see from the comments this callback action exchanges the request token for an access token. Since the user is going to need to type in the username and password at Twitter I avoid prompting for it and instead we fetch that using a call to verify_credentials. This saves duplicate entry and makes it easier on the user. This also prevents users with multiple accounts from giving you one username and then using another when they login to twitter. The access token and secret are what is needed to act on behalf of a user, so those are saved to the database. The show action then uses this information to display some data like so:</p>
<p>def show<br />
@user = User.find(params[:id])<br />
# Get this users favorites via OAuth<br />
@access_token = OAuth::AccessToken.new(UsersController.consumer, @user.token, @user.secret)<br />
RAILS_DEFAULT_LOGGER.error &#8220;Making OAuth request for #{@user.inspect} with #{@access_token.inspect}&#8221;<br />
@response = UsersController.consumer.request(:get, &#8216;/favorites.json&#8217;, @access_token,<br />
{ :scheme =&gt; :query_string })<br />
case @response<br />
when Net::HTTPSuccess<br />
@favorites = JSON.parse(@response.body)<br />
respond_to do |format|<br />
format.html # show.html.erb<br />
end<br />
else<br />
RAILS_DEFAULT_LOGGER.error &#8220;Failed to get favorites via OAuth for #{@user}&#8221;<br />
# The user might have rejected this application. Or there was some other error during the request.<br />
flash[:notice] = &#8220;Authentication failed&#8221;<br />
redirect_to :action =&gt; :index<br />
return<br />
end</p>
<p>Finally the views</p>
<p>&lt;p&gt;<br />
&lt;b&gt;Screen name:&lt;/b&gt;<br />
&lt;%=h @user.screen_name %&gt;<br />
&lt;/p&gt;<br />
&lt;ul&gt;<br />
&lt;% @favorites.each do |fav| %&gt;<br />
&lt;li&gt;&lt;b&gt;&lt;%= fav['user']['screen_name']  %&gt;&lt;/b&gt;: &lt;%=h fav['text']  %&gt;&lt;/li&gt;<br />
&lt;% end %&gt;<br />
&lt;/ul&gt;</p>
<p>and</p>
<p>the new.html.erb</p>
<p>&lt;h1&gt;New user&lt;/h1&gt;</p>
<p>&lt;% form_for(@user) do |f| %&gt;<br />
&lt;%= f.error_messages %&gt;<br />
&lt;p&gt;<br />
We&#8217;ll be sending you to Twitter in a moment to login and grant us access.<br />
Once you allow us in we&#8217;ll give you the super-cool feature<br />
you&#8217;bve heard about.<br />
&lt;/p&gt;<br />
&lt;p&gt;<br />
&lt;%= f.submit &#8220;Grant Access&#8221; %&gt;<br />
&lt;/p&gt;<br />
&lt;% end %&gt;<br />
&lt;%= link_to &#8216;Back&#8217;, users_path %&gt;</p>
<p>Also Add validates_presence_of to the User model for screen_name, token and secret.</p>
<p>And in the routes.rb set the following route</p>
<p>map.connect &#8216;/callback&#8217;, :controller =&gt; &#8216;users&#8217;, :action =&gt; &#8216;callback&#8217;</p>
<p>Thats it you are ready for the twitter Login. Start the server and open localhost:3000/users<br />
and you will see the magic.</p>
<p>These are all the steps. Post me a comment if you still face any isssues.</p>
<p>Please note : &#8211; This method might not function correctly now since the method of authentication has changed. Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/06/step-by-step-twitter-oauth-integration-with-rails/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>localization or internationalization in rails</title>
		<link>http://blog.dhavalparikh.co.in/2009/05/localization-or-internationalization-in-rails/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/05/localization-or-internationalization-in-rails/#comments</comments>
		<pubDate>Wed, 20 May 2009 09:46:22 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[globalite plugin]]></category>
		<category><![CDATA[globalite plugin error]]></category>
		<category><![CDATA[internationalization in rails]]></category>
		<category><![CDATA[localization in rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[time_select tag error]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/?p=203</guid>
		<description><![CDATA[Most of the new websites are having the feature of localization or internationalization on their site. With introduction of rails 2.3 this feature is provided by default But if you are still working in rails 2.0 or 2.1 then GlobalLite is the solution for you.. http://code.google.com/p/globalite/ How ever while implement it in one of my [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the new websites are having the feature of localization or internationalization on their site. With introduction of rails 2.3 this feature is provided by default But if you are still working in rails 2.0 or 2.1 then GlobalLite is the solution for you.. http://code.google.com/p/globalite/</p>
<p>How ever while implement it in one of my projects I noticed that the localized date time module used in the plugin has a problem when you have time_select tag in your form.</p>
<p>So when you use a time_select tag in your form it will generate an error message “Can’t convert nil into string”. The problem is in the file called localized_action_view.rb which you will find  in plugins/globalite/lib/rails folder.</p>
<p>Apply the code below to get it fixed</p>
<p>def select_month(date, options = {}, html_options = {})<br />
if options[:locale]<br />
@original_locale = Locale.code<br />
Locale.code = options[:locale]<br />
end<br />
val = date ? (date.kind_of?(Fixnum) ? date : date.month) : ”<br />
if options[:use_hidden]<br />
hidden_html(options[:field_name] || ‘month’, val, options)<br />
else<br />
month_options = []<br />
monthnames = :date_helper_month_names.l<br />
abbr_monthnames = :date_helper_abbr_month_names.l<br />
month_names = options[:use_month_names] || (options[:use_short_month] ? abbr_monthnames : monthnames)<br />
month_names.unshift(nil) if month_names.size &lt; 13<br />
1.upto(12) do |month_number|<br />
month_name = if options[:use_month_numbers]<br />
month_number<br />
elsif options[:add_month_numbers]<br />
month_number.to_s + ‘ &#8211; ‘ + month_names[month_number]<br />
else<br />
month_names[month_number]<br />
end</p>
<p>month_options &lt;&lt; ((val == month_number) ?<br />
%(&lt;option value=”#{month_number}” selected=”selected”&gt;#{month_name}&lt;/option&gt;\n) :<br />
%(&lt;option value=”#{month_number}”&gt;#{month_name}&lt;/option&gt;\n)<br />
)<br />
end<br />
@selector = select_html(options[:field_name] || ‘month’, month_options, options)<br />
Locale.code = @original_locale if options[:locale]<br />
return @selector<br />
end<br />
#  Locale.code = @original_locale if options[:locale]<br />
#  return @selector<br />
end</p>
<p>You may even Comment the date module in the code  plugins/globalite/lib/rails/localized_action_view.rb</p>
<p>this will make use of default rails date time. so nothing will get affected if you do this. But the solution mentioned about is a better one.</p>
<p>Njoi the power of Internationalization and make sure site global.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/05/localization-or-internationalization-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File column plugin not working with rails 2.2</title>
		<link>http://blog.dhavalparikh.co.in/2009/05/file-column-not-working-in-rails-22/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/05/file-column-not-working-in-rails-22/#comments</comments>
		<pubDate>Tue, 05 May 2009 10:38:23 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[file column]]></category>
		<category><![CDATA[file upload in rails]]></category>
		<category><![CDATA[filecolumn plugin]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/2009/05/file-column-not-working-in-rails-22/</guid>
		<description><![CDATA[Older version of file_coulmn plugin is not working in rails 2.2. If you want to get working in rails 2.2 then you need to modify file_coulmn.rb file. Update the line #619 in vendor/plugins/file_column/lib/file_column.rb from Inflector.underscore(self.name).to_s, to ActiveSupport::Inflector.underscore(self.name).to_s, Or you can download the latest plugin from the github.com: http://github.com/rust/file_column/ If you are looking to implement the [...]]]></description>
			<content:encoded><![CDATA[<p>Older version of file_coulmn plugin is not working in rails 2.2.</p>
<p>If you want to get working in rails 2.2 then you need to modify file_coulmn.rb file.</p>
<p>Update the line #619 in vendor/plugins/file_column/lib/file_column.rb from</p>
<p>Inflector.underscore(self.name).to_s,<br />
to<br />
ActiveSupport::Inflector.underscore(self.name).to_s,</p>
<p>Or you can download the latest plugin from the github.com: http://github.com/rust/file_column/</p>
<p>If you are looking to implement the old File column plugin you may visit</p>
<p>http://blog.dhavalparikh.co.in/2008/02/file-column-plugin/</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/05/file-column-not-working-in-rails-22/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Charts in Rails (gc4r)</title>
		<link>http://blog.dhavalparikh.co.in/2009/04/google-charts-in-rails-gc4r/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/04/google-charts-in-rails-gc4r/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 12:12:07 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[charts in rails]]></category>
		<category><![CDATA[gc4r]]></category>
		<category><![CDATA[gc4r in rails]]></category>
		<category><![CDATA[google charts]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/2009/04/google-charts-in-rails-gc4r/</guid>
		<description><![CDATA[Well I m going to cover the topic how to generate charts using rails. there are number of options available such as follows Here are the plugins through which we can generate charts in rails 1) Gruff charts http://nubyonrails.com/articles/gruff-graphing-library-for-ruby 2) Sparklines http://nubyonrails.com/articles/sparklines-graph-library-for-ruby 3) Scruffy charts http://scruffy.rubyforge.org/ 4) Ziya plugin http://liquidrail.com/2007/1/4/charting-the-rails/ (flash charts) I found google [...]]]></description>
			<content:encoded><![CDATA[<p>Well I m going to cover the topic how to generate charts using rails. there are number of options available such as follows</p>
<p>Here are the plugins through which we can generate <span class="il">charts</span> in rails</p>
<p>1) Gruff <span><span class="il">charts</span></span> <a href="http://nubyonrails.com/articles/gruff-graphing-library-for-ruby" target="_blank" onclick="pageTracker._trackPageview('/outgoing/nubyonrails.com/articles/gruff-graphing-library-for-ruby?referer=');">http://nubyonrails.com/articles/gruff-graphing-library-for-ruby</a></p>
<p>2) Sparklines <a href="http://nubyonrails.com/articles/sparklines-graph-library-for-ruby" target="_blank" onclick="pageTracker._trackPageview('/outgoing/nubyonrails.com/articles/sparklines-graph-library-for-ruby?referer=');">http://nubyonrails.com/articles/sparklines-graph-library-for-ruby</a></p>
<p>3) Scruffy <span><span class="il">charts</span></span> <a href="http://scruffy.rubyforge.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/scruffy.rubyforge.org/?referer=');">http://scruffy.rubyforge.org/</a></p>
<p>4) Ziya plugin <a href="http://liquidrail.com/2007/1/4/charting-the-rails/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/liquidrail.com/2007/1/4/charting-the-rails/?referer=');">http://liquidrail.com/2007/1/4/charting-the-<span>rails</span>/</a> (flash <span><span class="il">charts</span></span>)</p>
<p>I found google charts the best of these..( ofcourse that suited my requirements). The gc4r plugin in rails is really helpful for easy integration of google charts in your rails application.</p>
<p>Here is how Charts are generated by Google API.</p>
<p>Install: ruby script/plugin install http://gc4r.googlecode.com/svn/trunk/</p>
<p><strong>Supported features:</strong><br />
1.line chart<br />
2.bar chart (vertical and horizontal)<br />
3.pie chart (both 2D and 3D)<br />
4.title, title color and size<br />
5.data colors and legend<br />
6.data scaling<br />
7.multiple axis</p>
<p><strong>#Controller</strong><br />
use_google_charts</p>
<p><strong>#In method of controller</strong></p>
<p><em>Default Chart or Hello World Chart</em><br />
@chart = GoogleChart.new</p>
<p><em>Set the width of chart</em><br />
@chart = GoogleLineChart.new :width =&gt; 300, :height =&gt; 200</p>
<p><em>Set the data </em><br />
dataset = GoogleChartDataset.new :data =&gt; [10,50,4,10,16]<br />
data = GoogleChartData.new :datasets =&gt; dataset<br />
@chart = GoogleLineChart.new :width =&gt; 300, :height =&gt; 200<br />
@chart.data = data</p>
<p><em>add a chart title</em><br />
dataset = GoogleChartDataset.new :data =&gt; [10,50,4,10,16]<br />
data = GoogleChartData.new :datasets =&gt; dataset<br />
@chart = GoogleLineChart.new :width =&gt; 200, :height =&gt; 150, :title =&gt; ‘Java vs. Ruby Montly Job Opportunities’<br />
@chart.data = data</p>
<p><em>Set title in array instead of string</em><br />
dataset = GoogleChartDataset.new :data =&gt; [10,50,4,10,16]<br />
data = GoogleChartData.new :datasets =&gt; dataset<br />
@chart = GoogleLineChart.new :width =&gt; 200, :height =&gt; 150, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']<br />
@chart.data = data</p>
<p><em>Multiple data in chart</em><br />
dataset1 = GoogleChartDataset.new :data =&gt; [10,50,4,10,16]<br />
dataset2 = GoogleChartDataset.new :data =&gt; [99, 81, 25, 54, 80]<br />
data = GoogleChartData.new :datasets =&gt; [dataset1, dataset2]<br />
@chart = GoogleLineChart.new :width =&gt; 200, :height =&gt; 150, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']<br />
@chart.data = data</p>
<p><em>Add colors</em><br />
dataset1 = GoogleChartDataset.new :data =&gt; [10,50,4,10,16],:color =&gt; ‘FF0000?<br />
dataset2 = GoogleChartDataset.new :data =&gt;[99,81,25,54,80],:color =&gt; ‘0000FF’<br />
data = GoogleChartData.new :datasets =&gt; [dataset1, dataset2]<br />
@chart = GoogleLineChart.new :width =&gt; 200, :height =&gt; 150, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']<br />
@chart.data = data</p>
<p><em>Define legend</em><br />
dataset1 = GoogleChartDataset.new :data =&gt;[10,50,4,10,16],:color =&gt; ‘FF0000?, :title =&gt; ‘Java’<br />
dataset2 = GoogleChartDataset.new :data=&gt;[99,81,25,54,80],:color =&gt; ‘0000FF’, :title =&gt; ‘Ruby’<br />
data = GoogleChartData.new :datasets =&gt; [dataset1, dataset2]<br />
@chart = GoogleLineChart.new :width =&gt; 200, :height =&gt; 150, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']<br />
@chart.data = data</p>
<p><em>Define Axis</em><br />
dataset1 = GoogleChartDataset.new :data =&gt;[10,50,4,10,16],:color =&gt; ‘FF0000?, :title =&gt; ‘Java’<br />
dataset2 = GoogleChartDataset.new :data=&gt;[99,81,25,54,80],:color =&gt; ‘0000FF’, :title =&gt; ‘Ruby’<br />
data = GoogleChartData.new :datasets =&gt; [dataset1, dataset2]<br />
axis = GoogleChartAxis.new :axis  =&gt; [GoogleChartAxis::LEFT, GoogleChartAxis::BOTTOM]<br />
@chart = GoogleLineChart.new :width =&gt; 250, :height =&gt; 150, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']<br />
@chart.data = data<br />
@chart.axis = axis</p>
<p><em>Define Right and X Axis</em><br />
dataset1 = GoogleChartDataset.new :data=&gt; [10,50,4,10,16],:color =&gt; ‘FF0000?,  :title =&gt; ‘Java’<br />
dataset2 = GoogleChartDataset.new :data=&gt;[99,81,25,54,80],:color =&gt; ‘0000FF’, :title =&gt; ‘Ruby’<br />
data = GoogleChartData.new :datasets =&gt; [dataset1, dataset2]<br />
axis = GoogleChartAxis.new :axis  =&gt; [GoogleChartAxis::LEFT, GoogleChartAxis::BOTTOM,  GoogleChartAxis::RIGHT, GoogleChartAxis::BOTTOM]<br />
@chart = GoogleLineChart.new :width =&gt; 300, :height =&gt; 200, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']<br />
@chart.data = data<br />
@chart.axis = axis</p>
<p><em>Define Bar Chart:</em><br />
@chart = GoogleBarChart.new :width =&gt; 300, :height =&gt; 200, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities']</p>
<p><em>Define 3D Pie Chart:</em><br />
@chart = GooglePieChart.new :width =&gt; 400, :height =&gt; 200, :title =&gt; ['Java vs. Ruby', 'Montly Job Opportunities'], :chart_type  =&gt; GooglePieChart::PIE_3D</p>
<p><strong>#view:</strong><br />
&lt;%= image_tag @chart.to_url %&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/04/google-charts-in-rails-gc4r/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Stress/Benchmark Testing on rails with httperf</title>
		<link>http://blog.dhavalparikh.co.in/2009/04/stressbenchmark-testing-on-rails-with-httperf/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/04/stressbenchmark-testing-on-rails-with-httperf/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 07:53:31 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[Stress/Benchmark testing in rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/2009/04/stressbenchmark-testing-on-rails-with-httperf/</guid>
		<description><![CDATA[Want to do benchmark or stress testing on your rails applications? Then look @ httpref What is httpref? Httperf is a tool for measuring web server performance. It provides a flexible facility for generating various HTTP workloads and for measuring server performance. The focus of httperf is not on implementing one particular benchmark but on [...]]]></description>
			<content:encoded><![CDATA[<p>Want to do benchmark or stress testing on your rails applications? Then look @ httpref</p>
<p>What is httpref?</p>
<p>Httperf is a tool for measuring web server performance. It provides a flexible facility for generating various HTTP workloads and for measuring server performance. The focus of httperf is not on implementing one particular benchmark but on providing a robust, high-performance tool that facilitates the construction of both micro- and macro-level benchmarks. The three distinguishing characteristics of httperf are its robustness, which includes the ability to generate and sustain server overload, support for the HTTP/1.1 and SSL protocols, and its extensibility to new workload generators and performance measurements.</p>
<p>Source url : &#8211; http://www.hpl.hp.com/research/linux/httperf/</p>
<p>Steps to do</p>
<p>1) download httpref from <a href="http://sourceforge.net/projects/httperf/" onclick="pageTracker._trackPageview('/outgoing/sourceforge.net/projects/httperf/?referer=');">http://sourceforge.net/projects/httperf/</a></p>
<p>2) install the tool</p>
<p>3) check out commands on http://www.hpl.hp.com/research/linux/httperf/httperf-man-0.9.pdf</p>
<p>Thats all</p>
<p>Find out how many http requests your site can handle..</p>
<p>Njoi</p>
<p>For more info you can post comments here</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/04/stressbenchmark-testing-on-rails-with-httperf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Export data to Excel (xls) in Ruby on Rails</title>
		<link>http://blog.dhavalparikh.co.in/2009/04/export-to-excel-in-ruby-on-rails/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/04/export-to-excel-in-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 14:04:48 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[export excel xls]]></category>
		<category><![CDATA[export to xls in rails]]></category>
		<category><![CDATA[rails xls]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/?p=196</guid>
		<description><![CDATA[The code Below will help to export the data in excel in Ruby on Rails #Controller class UserController &#60; ApplicationController def export headers['Content-Type'] = "application/vnd.ms-excel" headers['Content-Disposition'] = 'attachment; filename="report.xls"' headers['Cache-Control'] = '' @users = User.find(:all) end #View export.html.erb &#60;%= link_to "Export as Excel", export_person_url %&#62; _report.html.erb &#60;table border="1"&#62; &#60;tr&#62; &#60;th&#62;Name&#60;/th&#62; &#60;/tr&#62; &#60;% @users.each do &#124;u&#124; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The code Below will help to export the data in excel in Ruby on Rails</strong></p>
<p><strong><em>#Controller</em></strong></p>
<pre><span class="keyword">class </span><span class="class">UserController</span> <span class="punct">&lt;</span> <span class="constant">ApplicationController</span>
  <span class="keyword">def </span><span class="method">export</span>
    <span class="ident">headers</span><span class="punct">['</span><span class="string">Content-Type</span><span class="punct">']</span> <span class="punct">=</span> <span class="punct">"</span><span class="string">application/vnd.ms-excel</span><span class="punct">"</span>
    <span class="ident">headers</span><span class="punct">['</span><span class="string">Content-Disposition</span><span class="punct">']</span> <span class="punct">=</span> <span class="punct">'</span><span class="string">attachment; filename="report.xls"</span><span class="punct">'</span>
    <span class="ident">headers</span><span class="punct">['</span><span class="string">Cache-Control</span><span class="punct">']</span> <span class="punct">=</span> <span class="punct">'</span><span class="punct">'</span>
    <span class="attribute">@users</span> <span class="punct">=</span> <span class="constant">User</span><span class="punct">.</span><span class="ident">find</span><span class="punct">(</span><span class="symbol">:all</span><span class="punct">)</span>
  <span class="keyword">end</span></pre>
<p><em><strong>#View</strong></em></p>
<p><em>export.html.erb</em></p>
<pre><span class="punct">&lt;%=</span><span class="string"> link_to "Export as Excel", export_person_url %&gt;</span></pre>
<p><em>_report.html.erb</em></p>
<pre><span class="punct">&lt;</span><span class="ident">table</span> <span class="ident">border</span><span class="punct">="</span><span class="string">1</span><span class="punct">"&gt;</span>
  <span class="punct">&lt;</span><span class="ident">tr</span><span class="punct">&gt;</span>
    <span class="punct">&lt;</span><span class="ident">th</span><span class="punct">&gt;</span><span class="constant">Name</span><span class="punct">&lt;/</span><span class="regex">th&gt;
  &lt;</span><span class="punct">/</span><span class="ident">tr</span><span class="punct">&gt;</span>
  <span class="punct">&lt;%</span> <span class="attribute">@users</span><span class="punct">.</span><span class="ident">each</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">u</span><span class="punct">|</span> <span class="punct">%&gt;</span><span class="string">
  &lt;tr</span><span class="punct">&gt;</span>
 <span class="punct">  &lt;</span><span class="ident">td</span><span class="punct">&gt;&lt;%=</span><span class="string"> u.name %&gt;&lt;/td&gt;
  &lt;% end %&gt;
 &lt;/tr&gt;
&lt;/table&gt;</span></pre>
<p>Please note :- This method might might be deprecated. You may visit http://spreadsheet.rubyforge.org/ for more info. Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/04/export-to-excel-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Progress Bar in Rails</title>
		<link>http://blog.dhavalparikh.co.in/2009/04/progress-bar-in-rails/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/04/progress-bar-in-rails/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 10:00:59 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[progress bar]]></category>
		<category><![CDATA[progress bar in rails]]></category>
		<category><![CDATA[rails progress bar]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/2009/04/progress-bar-in-rails/</guid>
		<description><![CDATA[Ever thought of implementing a progress bar in rails? or did a need arise for you to do the same? Something like if you want the user to show the progress bar while he is uploading the file and so on Well there is a plugin available which will help you to do the same.. [...]]]></description>
			<content:encoded><![CDATA[<p>Ever thought of implementing a progress bar in rails? or did a need arise for you to do the same?</p>
<p>Something like if you want the user to show the progress bar while he is uploading the file and so on</p>
<p>Well there is a plugin available which will help you to do the same.. Here are the details for it</p>
<p>ProgressBar Plugin:</p>
<p>Install: ruby script/plugin install http://progressbarhelper.googlecode.com/svn/trunk/progress_bar_helper/</p>
<p>#View -</p>
<p>Include JS Files<br />
&lt;%=javascript_include_tag “progress_bar/jsProgressBarHandler.js”%&gt;</p>
<p>Custom Static Progress Bar:<br />
custom_static_progress_bar(name, value, options = {})</p>
<p>Options are:<br />
# * name : used as an id for the progress bar<br />
# * value : decimal value to represent (i.e. value &lt;= 1)<br />
# * options : rendering options<br />
#<br />
# Rendering options are:<br />
# * show_text : set to true to display percentage value in a text form<br />
# * animate : set to true to animate the image<br />
# * width : sets the width of the image (!must be the same as the actual box_image width<br />
# * height : sets the height of the image (!must be the same as the actual box_image height<br />
# * box_image : sets the container image<br />
# * bar_images : sets the progress bar images (must be an Array)</p>
<p>Example:<br />
&lt;%=custom_static_progress_bar(”a2?,1.0,{:show_text=&gt;”Test”,:animate=&gt;true,:width=&gt;120,:height=&gt;12})%&gt;</p>
<p>Progress Bar:<br />
progress_bar(name,value, display_percentage_text = false, multicolor = false)</p>
<p>Njoi A gr8 progress bar.</p>
<p>Thanks</p>
<p>Dhaval Parikh</p>
<p>http://www.dhavalparikh.co.in</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/04/progress-bar-in-rails/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>.htaccess protection with nginx</title>
		<link>http://blog.dhavalparikh.co.in/2009/01/htaccess-protection-with-nginx/</link>
		<comments>http://blog.dhavalparikh.co.in/2009/01/htaccess-protection-with-nginx/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 08:54:12 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[htaccess on nginx]]></category>
		<category><![CDATA[htaccess on rails]]></category>
		<category><![CDATA[nginx htaccess]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/?p=160</guid>
		<description><![CDATA[Hey just recently had a requirement where in I had to set password for my website. It was a ruby on rails website and I had to set .htaccess for it. I knew how to setup .htaccess for apache but with nginx (that our site was using as webserver) I didnt knew what to do. [...]]]></description>
			<content:encoded><![CDATA[<p>Hey just recently had a requirement where in I had to set password for my website. It was a ruby on rails website and I had to set .htaccess for it. I knew how to setup .htaccess for apache but with nginx (that our site was using as webserver) I didnt knew what to do.</p>
<p>Then I figured out the solution</p>
<p>Open nginx.conf file. Search for the location word you might see multiple location configuration. But put the code below in the root location</p>
<pre class="code" style="height: 500px;">            auth_basic "RESTRICTED ACCESS";
            auth_basic_user_file /path/to/htpasswd/file

For ruby on rails it will be generally in
 the public folder of your rails app.

If you havent generated the htpassword
yet pls do it using the following command 

htpasswd -b -c htpasswd username password

Hope this will be useful to you if you
 are caught in the same situation as me.

Njoi protecting the site</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2009/01/htaccess-protection-with-nginx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Spam filtering in rails using Akismet</title>
		<link>http://blog.dhavalparikh.co.in/2008/12/spam-filtering-in-rails-using-akismet/</link>
		<comments>http://blog.dhavalparikh.co.in/2008/12/spam-filtering-in-rails-using-akismet/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 05:40:00 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[Akismet with rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[spam filtering with rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/?p=26</guid>
		<description><![CDATA[SPAM!!!! is a very big problem for all big applications. If you are having a site which allows users to comment on ur posts and so on then you might get affected by spamming. Akismet is something which is helping us to avoid spamming on our sites. There is a rails plugin available at http://github.com/jfrench/rakismet/tree/master [...]]]></description>
			<content:encoded><![CDATA[<p>SPAM!!!! is a very big problem for all big applications. If you are having a site which allows users to comment on ur posts and so on then you might get affected by spamming.</p>
<p>Akismet is something which is helping us to avoid spamming on our sites.</p>
<p>There is a rails plugin available at http://github.com/jfrench/rakismet/tree/master</p>
<p>You can download this and configure akismet in your rails app. more information is provided in read me file of the plugin.</p>
<p>IF you want to see the actual implementation you can watch a screencast on</p>
<p>http://railscasts.com/episodes/65-stopping-spam-with-akismet</p>
<p>Hope this is some useful information for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2008/12/spam-filtering-in-rails-using-akismet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counter Cache in rails 2.1</title>
		<link>http://blog.dhavalparikh.co.in/2008/12/counter-cache-in-rails-21/</link>
		<comments>http://blog.dhavalparikh.co.in/2008/12/counter-cache-in-rails-21/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 07:00:00 +0000</pubDate>
		<dc:creator>Dhaval Parikh</dc:creator>
				<category><![CDATA[counter cache]]></category>
		<category><![CDATA[counter cache in rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dhavalparikh.co.in/?p=25</guid>
		<description><![CDATA[Counter cache is really an important feature in rails 2.1 . This method is really helpful when u want to keep a count on something and avoid firing sql query every time which results in more processing times. Here it goes To activate this feature, you need to take two simple steps. First, add the [...]]]></description>
			<content:encoded><![CDATA[<p>Counter cache is really an important feature in rails 2.1 . This method is really helpful when u want to keep a count on something and avoid firing sql query every time which results in more processing times.</p>
<p>Here it goes</p>
<p>To activate this feature, you need to take two simple steps. First, add the<br />
option :counter_cache to the belongs_to declaration in the child table.</p>
<p>class LineItem &lt; counter_cache =&#8221;"&gt; true<br />
end</p>
<p>Second, in the definition of the parent table (products in this example) you<br />
need to add an integer column whose name is the name of the child table with<br />
_count appended.</p>
<p>create_table :products, :force =&gt; true do |t|<br />
t.column :title, :string<br />
t.column :description, :text<br />
# &#8230;<br />
t.column :line_items_count, :integer, :default =&gt; 0<br />
end</p>
<p>Thats it .. Counter cache is enabled now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dhavalparikh.co.in/2008/12/counter-cache-in-rails-21/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

