<?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>Sentia &#124; Sydney IT Consultancy, Software Development, Ruby on Rails, Web Application Development, Rails Development, Test Driven Development, Microsoft.Net, Asp.Net , Agile, Continuous Integration Training, iPhone development &#187; ruby on rails</title>
	<atom:link href="http://www.sentia.com.au/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sentia.com.au</link>
	<description>Sentia company website and blog about all things development, Ruby on Rails, Microsoft .Net, ASP.Net, C#.Net, Agile web development, Test Driven Development</description>
	<lastBuildDate>Fri, 27 Aug 2010 05:10:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Learning Ruby On Rails</title>
		<link>http://www.sentia.com.au/2010/04/learning-ruby-on-rails/</link>
		<comments>http://www.sentia.com.au/2010/04/learning-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 00:37:02 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[learing rails]]></category>

		<guid isPermaLink="false">http://www.sentia.com.au/?p=704</guid>
		<description><![CDATA[Hey spoken to a few developers mainly UNI grads who are looking to get into rails and they often ask whats the best way to do so. So l thought l would put together a list of resources they can use to get up to speed.
If anyone else knows of some other ones please let [...]]]></description>
			<content:encoded><![CDATA[<p>Hey spoken to a few developers mainly UNI grads who are looking to get into rails and they often ask whats the best way to do so. So l thought l would put together a list of resources they can use to get up to speed.</p>
<p>If anyone else knows of some other ones please let me know</p>
<p>== General Practices ==<br />
Dev on a Mac<br />
Read up on TDD (Test Driven Development)<br />
Use Growl for your Autotest notifications<br />
<a href="http://macromates.com/">TextMate</a> &#8211; The only Editor you need<br />
<a href="http://github.com">GitHub</a> &#8211; Great space to see open source code and gems and plugins<br />
<a href="http://gemcutter.org/">http://gemcutter.org/</a></p>
<p>== Rails Setup ==</p>
<p><a href="http://hivelogic.com/">http://hivelogic.com/</a> &#8211; Has some great tutorials on getting your environment setup on a mac.</p>
<p>== Tutorials ==<br />
<a href="http://rubyonrails.org">http://rubyonrails.org</a><br />
<a href="http://railscasts.com">Rails Casts</a> &#8211; Ryan Bates screen casts about all things rails related<br />
<a href="https://peepcode.com">PeepCode</a> &#8211; Great screen casts about all things rails related</p>
<p>== Blogs ==</p>
<p><a href="http://sentia.com.au/blog">Sentia Blog</a><br />
<a href="http://thoughtbot.com/">http://thoughtbot.com</a><br />
<a href="http://weblog.jamisbuck.org">http://weblog.jamisbuck.org</a><br />
<a href="http://blog.jayfields.com">http://blog.jayfields.com</a><br />
<a href="http://errtheblog.com">http://errtheblog.com</a></p>
<p>== Books ==<br />
<a href="http://pragmaticstudio.com">http://pragmaticstudio.com</a> &#8211; Great source of books about rails and other technologies with a focus on the right practices.</p>
<p>Finally the only real way to learn is to try things out. Follow other developers blogs and use all the resources you can such as Google groups etc.<br />
Don&#8217;t be scared to get it wrong its the only way to learn.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2010/04/learning-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PayFlow recurring billing with ActiveMerchant</title>
		<link>http://www.sentia.com.au/2009/10/payflow-recurring-billing-with-activemerchant/</link>
		<comments>http://www.sentia.com.au/2009/10/payflow-recurring-billing-with-activemerchant/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 04:47:47 +0000</pubDate>
		<dc:creator>James Kong</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[activemerchant]]></category>
		<category><![CDATA[Payflow]]></category>
		<category><![CDATA[Payment Gateway]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Recurring Billing]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=612</guid>
		<description><![CDATA[Today we are going to look at using ActiveMerchant to set up a recurring billing subscription with PayFlow .
PayFlow is Paypal&#8217;s payment gateway and you need to setup a PayFlow account.
IMPORTANT! This is separate from Paypal&#8217;s development sandbox. Follow these steps to setup a Payflow testing account

Go to https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-get-started-outside
 and fill in the details for [...]]]></description>
			<content:encoded><![CDATA[<p>Today we are going to look at using ActiveMerchant to set up a recurring billing subscription with PayFlow .</p>
<p>PayFlow is Paypal&#8217;s payment gateway and you need to setup a PayFlow account.<br />
<strong>IMPORTANT!</strong> This is separate from Paypal&#8217;s development sandbox. Follow these steps to setup a Payflow testing account</p>
<ol>
<li>Go to <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-get-started-outside">https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-get-started-outside<br />
</a> and fill in the details for an account.</li>
<li>When you get to the page where you need to enter your payment information, hit Save and Exit. This will create a testing PayFlow account for you.</li>
<li>You will be sent an email with your partner ID and your vendor login. Take note of your partner ID as this will be important later.</li>
<li>You should now be able to login at <a href="https://manager.paypal.com/">https://manager.paypal.com/</a></li>
</ol>
<p>Now that you have a PayFlow account, you can use ActiveMerchant to setup payments. For now we will muck around in irb to test that methods out.</p>
<p>So lets open up irb and start by including the active merchant gem and setting ActiveMerchant to test mode</p>
<pre class="brush: ruby;">
kongy@Deadpool: $ irb
irb(main):001:0&gt; require 'rubygems'
irb(main):002:0&gt; require 'active_merchant'
irb(main):003:0&gt; ActiveMerchant::Billing::Base.mode = :test
</pre>
<p>Now lets setup the gateway.</p>
<pre class="brush: ruby;">
gateway = ActiveMerchant::Billing::PayflowGateway.new(:login =&gt; 'PAYFLOW_LOGIN', :password =&gt; 'PAYFLOW_PASSWORD', :partner =&gt; 'PARTNER_ID')
</pre>
<p>This creates the gateway that we will be using to request purchases. By default ActiveMerchant passes PAYPAL as the partner value if you leave it out. I believe that this is the default for US PayFlow account. For my Aussie one, I received a VSA partner_id. I would suggest putting it in there anyway.</p>
<p>PayFlow Testing only accepts testing credit cards numbers.  You can grab them from the PayFlow recurring billing documentation found <a href="https://cms.paypal.com/cms_content/US/en_US/files/developer/PayflowPro_RecurringBilling_Guide.pdf">here</a>. Here is a quick list which I can&#8217;t guarantee will be up to date.</p>
<table border="0">
<tbody>
<tr>
<td>American Express</td>
<td>378282246310005</td>
</tr>
<tr>
<td>American Express</td>
<td>371449635398431</td>
</tr>
<tr>
<td>American Express Corporate</td>
<td>378734493671000</td>
</tr>
<tr>
<td>Diners Club</td>
<td>30569309025904</td>
</tr>
<tr>
<td>Diners Club</td>
<td>38520000023237</td>
</tr>
<tr>
<td>Discover</td>
<td>6011111111111117</td>
</tr>
<tr>
<td>Discover</td>
<td>6011000990139424</td>
</tr>
<tr>
<td>JCB</td>
<td>3530111333300000</td>
</tr>
<tr>
<td>JCB</td>
<td>3566002020360505</td>
</tr>
<tr>
<td>MasterCard</td>
<td>5555555555554444</td>
</tr>
<tr>
<td>MasterCard</td>
<td>5105105105105100</td>
</tr>
<tr>
<td>Visa</td>
<td>4111111111111111</td>
</tr>
<tr>
<td>Visa</td>
<td>4012888888881881</td>
</tr>
<tr>
<td>Visa</td>
<td>4222222222222</td>
</tr>
</tbody>
</table>
<p>So lets create a Mastercard credit card.</p>
<pre class="brush: ruby;">
irb(main):004:0&gt; credit_card = ActiveMerchant::Billing::CreditCard.new( :number =&gt; '5105105105105100', :month =&gt; '9', :year =&gt; '2007', :first_name =&gt; 'Mal', :last_name =&gt; 'Reynolds', :verification_value =&gt; '123', :type =&gt; 'master' )
</pre>
<p>Now we are ready to start billing. If you want to setup a one time payment it is quite easy.</p>
<pre class="brush: ruby;">
irb(main):007:0&gt; response = gateway.purchase(1000, credit_card)
irb(main):008:0&gt; response.success?
=&gt; true
</pre>
<p>If you go into your Paypal Manager and search for transactions you should see it appear.</p>
<p>To setup a recurring billing we need to use the <b>recurring</b> method of the gateway. The recurring method accepts the amount in cents, the credit card object and the time intervals to charge the card, at a minimum. There are other options available which you can find <a href="http://activemerchant.rubyforge.org/classes/ActiveMerchant/Billing/PayflowGateway.html">here</a>. Lets charge $10/month</p>
<pre class="brush: ruby;">
irb(main):009:0&gt; response = gateway.recurring(100, credit_card, :periodicity =&gt; :monthly)
irb(main):010:0&gt; response.success?
=&gt; true
irb(main):011:0&gt; response.profile_id
=&gt; &quot;RT0000000002&quot;
</pre>
<p>You can view the recurring billings in your Paypal Manager by clicking on Service Settings > Recurring Billings > Manage Profiles. You will probably want to store the profile_id in your database for when you need to edit details of the recurring billing. You can do it quite simply by calling the <b>recurring</b> method again. Let&#8217;s change the amount we want to bill to $20/week.</p>
<pre class="brush: ruby;">
irb(main):0012:0&gt; response = gateway.recurring(2000, nil, :profile_id =&gt; &quot;RT0000000001&quot;,  :periodicity =&gt; :weekly)
irb(main):013:0&gt; response.success?
=&gt; true
</pre>
<p>You can see here that we no longer need to pass in the credit card since we have the profile_id. We update the amount, and change the periodicity of the billing.</p>
<p>And that&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/10/payflow-recurring-billing-with-activemerchant/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>When to use Nested Controllers in your Rails apps</title>
		<link>http://www.sentia.com.au/2009/09/when-to-use-nested-controllers-in-your-rails-apps/</link>
		<comments>http://www.sentia.com.au/2009/09/when-to-use-nested-controllers-in-your-rails-apps/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 00:27:43 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[nested controllers]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=575</guid>
		<description><![CDATA[Nested controllers are great. I don&#8217;t care that they have a stigma attached to them they work well and make sense especially if your rails application has a Admin section for example. This allows you to easy separate the admin logic into its own controllers etc keeping your code clean and easy to manage.
So thats [...]]]></description>
			<content:encoded><![CDATA[<p>Nested controllers are great. I don&#8217;t care that they have a stigma attached to them they work well and make sense especially if your rails application has a Admin section for example. This allows you to easy separate the admin logic into its own controllers etc keeping your code clean and easy to manage.</p>
<p>So thats what we are going to do for this example.</p>
<h2>Step 1.  Create your admin controller</h2>
<p>You can use whichever process works best for you, but for this we are going to use script/generate:</p>
<pre class="brush: ruby;">
 ./script/generate controller admin
</pre>
<h2>Step 2.  Create your user controller</h2>
<p>You can use whichever process works best for you, but for this we are going to use script/generate:</p>
<pre class="brush: ruby;">
 ./script/generate controller admin/users
</pre>
<h2>Step 3.  Check to ensure proper inheritance</h2>
<p>The nested users controller should look something like so:</p>
<pre class="brush: ruby;">
class Admin::UsersController &lt; ApplicationController
end
</pre>
<h2>Step 4. Create the Routes</h2>
<p>The nested users controller should look something like so:</p>
<pre class="brush: ruby;">
map.namespace :admin do |admin|
  admin.resources :users
end
</pre>
<p>Before rails 2+ you had to do like like we have below. Personally l don&#8217;t mind it makes it a little easier to read but either option works fine</p>
<pre class="brush: ruby;">
map.resource(:admin) do |admin|
  admin.resources(:users, :controller =&gt; 'admin/users')
end
</pre>
<h2>Step 5. Wait there is no step 5 your done</h2>
<p>Now when you need to link to any of these actions its very simple keeping in mind that users is nested under the admin controller so all you have to do to create a link that goes to the index action on the nested users controller is add the admin prefix before</p>
<pre class="brush: ruby;">
 link_to &quot;Users&quot;, admin_users_url
</pre>
<p>The same applies when you are wanting to link to the show action of users all you do is loose the &#8220;s&#8221; on users as you would normally</p>
<pre class="brush: ruby;">
 link_to &quot;View User&quot;, admin_user_url(@user)
</pre>
<p>You can see a list of all the routes you have available to you by going to the root directory of your project in terminal and typing</p>
<pre class="brush: ruby;">
rake routes
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/09/when-to-use-nested-controllers-in-your-rails-apps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using passenger to run your rails applications when developing</title>
		<link>http://www.sentia.com.au/2009/09/using-passenger-to-run-your-rails-applications-when-developing/</link>
		<comments>http://www.sentia.com.au/2009/09/using-passenger-to-run-your-rails-applications-when-developing/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 07:21:04 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[mac osx]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=494</guid>
		<description><![CDATA[If your like me and sick of having to run ./script/server every time you want to start your rails app using passenger locally is for you then. First thing is to install passenger like so

sudo gem install passenger

Then you need to install the apache module for passenger.

sudo passenger-install-apache2-module

Now once you do this you will be [...]]]></description>
			<content:encoded><![CDATA[<p>If your like me and sick of having to run ./script/server every time you want to start your rails app using passenger locally is for you then. First thing is to install passenger like so</p>
<pre class="brush: ruby;">
sudo gem install passenger
</pre>
<p>Then you need to install the apache module for passenger.</p>
<pre class="brush: ruby;">
sudo passenger-install-apache2-module
</pre>
<p>Now once you do this you will be told to all the following lines to your httpd.conf file in apache. Now you can just add these lines no problems but l like to have it in its own conf file and since apache will also load all conf files in /etc/apache2/other/ directory just create a  passenger.conf file and add those lines in. Now these lines are different depending on how you installed ruby. I installed it in user/local keeping the orginal ruby version that ships with mac clean so mine looks like so</p>
<pre class="brush: ruby;">
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.5
PassengerRuby /usr/local/bin/ruby
</pre>
<p>To create the new passenger.conf file just run the below command assuming you have textmate installed.</p>
<pre class="brush: ruby;">
mate /etc/apache2/other/passenger.conf
</pre>
<p>Once you have cut and pasted those lines in save it and close the file. You then need to download the <a href=" http://www.fngtps.com/passenger-preference-pane">passenger preference pane</a>. Here is a link to the latest build <a href="http://www.fngtps.com/files/2/2009/09/PassengerPane-1.3.tgz">passenger-preference-pane1.3</a>. Download and install then fire it up.</p>
<p><img src="http://sentia.com.au/wp-content/uploads/2009/09/passenger_preference_pane.png" alt="Passenger preference pane"  height="382px" width="500px" title="Using passenger to run your rails applications when developing" /></p>
<p>Now unlock it if need be and click on the + button to add a new site. A window will pop up and now just select the root of your rails app and click &#8220;open&#8221;. You can now change the address if need be but just defaults to (rails_app_name).local. Hit apply and your good to go.</p>
<p>So go back to your browser and type in that address and it will fire up and your up and running. Now you wont see the log like you are used to since your not running webrick etc but all you have to do is tail the development log by going to the root dir of your application in terminal and typing the following</p>
<pre class="brush: ruby;">
 tail -f log/development.log
</pre>
<p>And that&#8217;s it. You will need to restart passenger if you change the environment.rb file but thats simple enough via the preference pane. So no more ./script/server yay</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/09/using-passenger-to-run-your-rails-applications-when-developing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>no such file to load &#8212; capistrano/ext/multistage</title>
		<link>http://www.sentia.com.au/2009/09/no-such-file-to-load-capistranoextmultistage/</link>
		<comments>http://www.sentia.com.au/2009/09/no-such-file-to-load-capistranoextmultistage/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 06:55:02 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[mac osx]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=488</guid>
		<description><![CDATA[I ran into this error the other day when running &#8220;cap -T&#8221;
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#8217;: no such file to load &#8212; capistrano/ext/multistage (LoadError)
So to fix this l did the following
sudo gem uninstall capistrano
sudo rm -rf /usr/bin/cap
sudo gem install capistrano-ext
sudo gem install capistrano
Needed to do &#8220;sudo rm -rf /usr/bin/cap&#8221; as doing just the uninstall of capistrano didn&#8217;t remove [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into this error the other day when running &#8220;cap -T&#8221;</p>
<blockquote><p>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#8217;: no such file to load &#8212; capistrano/ext/multistage (LoadError)</p></blockquote>
<p>So to fix this l did the following</p>
<blockquote><p>sudo gem uninstall capistrano<br />
sudo rm -rf /usr/bin/cap<br />
sudo gem install capistrano-ext<br />
sudo gem install capistrano</p></blockquote>
<p>Needed to do &#8220;sudo rm -rf /usr/bin/cap&#8221; as doing just the uninstall of capistrano didn&#8217;t remove all the files l needed it to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/09/no-such-file-to-load-capistranoextmultistage/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up a new Rails app with Git</title>
		<link>http://www.sentia.com.au/2009/09/setting-up-a-new-rails-app-with-git/</link>
		<comments>http://www.sentia.com.au/2009/09/setting-up-a-new-rails-app-with-git/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 03:15:40 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[source control]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=479</guid>
		<description><![CDATA[Ok so you want to be cool like all other rails developers out there and use Git for your projects. Here is a quick run down of how you might go about it.
Firstly create your rails app and using terminal go into the root of that project.
Then create a top, project-level .gitignore file. I use [...]]]></description>
			<content:encoded><![CDATA[<p>Ok so you want to be cool like all other rails developers out there and use Git for your projects. Here is a quick run down of how you might go about it.</p>
<p>Firstly create your rails app and using terminal go into the root of that project.</p>
<p>Then create a top, project-level .gitignore file. I use textmate so this can be done like so</p>
<pre class="brush: ruby;">
$ mate .gitignore
</pre>
<p>Then add the following to the .gitignore file</p>
<pre class="brush: ruby;">
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
</pre>
<p>You can also add more directories or files in here to ignore like css files if using sass for example, or your uploads directory.</p>
<p>Create some .gitignore files so the empty directories get tracked:</p>
<pre class="brush: ruby;">
$ touch log/.gitignore
$ touch tmp/.gitignore
</pre>
<p>and finally commit that bad boy</p>
<pre class="brush: ruby;">
$ git add .
$ git commit -m &quot;First commit&quot;
</pre>
<p>Running git add will tell git to track all the new files (Since first commit thats all of them). The commit will commit to your local Git repository and all that is left to do would be to add it to GitHub for example and your in business.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/09/setting-up-a-new-rails-app-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restarting your rails application after deployment on Passenger</title>
		<link>http://www.sentia.com.au/2009/09/restarting-your-rails-application-after-deployment-on-passenger/</link>
		<comments>http://www.sentia.com.au/2009/09/restarting-your-rails-application-after-deployment-on-passenger/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 00:43:02 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[passenger]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=476</guid>
		<description><![CDATA[This is something that l always forget to add the first time l deploy my rails applications that run on Apache + Passenger.

namespace :deploy do
  desc &#34;Restarting mod_rails with restart.txt&#34;
  task :restart, :roles =&#62; :app, :except =&#62; { :no_release =&#62; true } do
    run &#34;touch #{current_path}/tmp/restart.txt&#34;
  end

  [:start, [...]]]></description>
			<content:encoded><![CDATA[<p>This is something that l always forget to add the first time l deploy my rails applications that run on Apache + Passenger.</p>
<pre class="brush: ruby;">
namespace :deploy do
  desc &quot;Restarting mod_rails with restart.txt&quot;
  task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
    run &quot;touch #{current_path}/tmp/restart.txt&quot;
  end

  [:start, :stop].each do |t|
    desc &quot;#{t} task is a no-op with mod_rails&quot;
    task t, :roles =&gt; :app do ; end
  end
end
</pre>
<p>This will tell Capistrano to restart the server the passenger way by touching the restart.txt file in the tmp dir rather then trying to restart using mongrel. Lets hope l don&#8217;t forget next time</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/09/restarting-your-rails-application-after-deployment-on-passenger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone application intergration with Web Application</title>
		<link>http://www.sentia.com.au/2009/08/iphone-application-intergration-with-web-application/</link>
		<comments>http://www.sentia.com.au/2009/08/iphone-application-intergration-with-web-application/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 04:13:14 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[application development]]></category>
		<category><![CDATA[ruby on]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=354</guid>
		<description><![CDATA[We are working on integrating an iPhone application with a Ruby on Rails web application. Its actually not that hard, the ObjectResource framework which was developed by Ryan Daigle. It works really well and allows you to easy interact with your rails application with little hassle.
Ill post more about this soon
]]></description>
			<content:encoded><![CDATA[<p>We are working on integrating an iPhone application with a Ruby on Rails web application. Its actually not that hard, the <a href="http://www.iphoneonrails.com/">ObjectResource</a> framework which was developed by Ryan Daigle. It works really well and allows you to easy interact with your rails application with little hassle.</p>
<p>Ill post more about this soon</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/08/iphone-application-intergration-with-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comatose, Authlogic and FCKEditor</title>
		<link>http://www.sentia.com.au/2009/08/comatose-authlogic-and-fckeditor/</link>
		<comments>http://www.sentia.com.au/2009/08/comatose-authlogic-and-fckeditor/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 23:47:44 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[authlogic]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[comatose]]></category>
		<category><![CDATA[fckeditor]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=309</guid>
		<description><![CDATA[Ok so we are using comatose and Authlogic for an app we are building for a client. We also wanted to use FCKEditor for comatose to give it a little more buzz.
Firstly you need to install Comatose. Go to your project root directory in terminal and type the following.

./script/plugin source http://mattmccray.com/svn/rails/plugins
./script/plugin install comatose
./script/generate comatose_migration
rake migrate

Then [...]]]></description>
			<content:encoded><![CDATA[<p>Ok so we are using comatose and Authlogic for an app we are building for a client. We also wanted to use FCKEditor for comatose to give it a little more buzz.</p>
<p>Firstly you need to install Comatose. Go to your project root directory in terminal and type the following.</p>
<pre class="brush: ruby;">
./script/plugin source http://mattmccray.com/svn/rails/plugins
./script/plugin install comatose
./script/generate comatose_migration
rake migrate
</pre>
<p>Then you need to install fckEditor. To do so go to the root of your app in terminal and type the following</p>
<pre class="brush: ruby;">
ruby script/plugin install svn://rubyforge.org//var/svn/fckeditorp/trunk/fckeditor
</pre>
<p>In the Comatose _form.html.erb page you need to change</p>
<pre class="brush: ruby;">
&lt;%= f.text_area :body, :rows=&gt;20, :tabindex=&gt;2 %&gt;
</pre>
<p>to this so that the fckeditor appears when creating and editing pages.</p>
<pre class="brush: ruby;">
&lt;%= fckeditor_textarea('page', 'body', :width =&gt; '100%', :height =&gt; '500px') %&gt;
</pre>
<p>Once you have Comatose and FCKEditor installed and running the final step is to get it all working with Authlogic.</p>
<p>So in your environment.rb file you need to add the following.</p>
<pre class="brush: ruby;">
Comatose.configure do |config|
  #Custom class we wrote to handle current_user etc
  config.admin_includes &lt;&lt; :user_methodss
  # Calls :login_required as a before_filter
    config.admin_authorization = :require_user
end
</pre>
<p>This will force comatose to have require a user to be logged in to use the system. The :user_methodss class is a class we wrote to handle the login methods of Autlogic. You can replace this with your own if you want ill include the class we created below.</p>
<pre class="brush: ruby;">
module UserMethods
  module ClassMethods
    def permission_required(permission_name,actions, notice=nil)
      notice ||= &quot;You don't have access to that part of the site.&quot;
      actions = [actions].flatten
      before_filter(:only =&gt; actions) { |controller| require_or_redirect(permission_name, controller, notice) }
    end

    def require_or_redirect(permission_name, controller, notice)
      user = controller.send(:current_user)

      if !user.can?(permission_name)
        # @permission_missing is used for should_require_permission test
        controller.instance_variable_set(&quot;@permission_missing&quot;, true)
        controller.send(:redirect_back_or_to, &quot;/&quot;, notice)
      end
    end
  end

  def self.included(base)
    base.extend(ClassMethods)
  end

  protected 

  # Redirects back or if that fails, redirects to the supplied path
  # Also accepts a notice if you want to flash something
  def redirect_back_or_to(path, notice=nil)
    flash[:notice] = notice unless notice.blank?
    begin
      redirect_to :back
    rescue ActionController::RedirectBackError
      redirect_to path
    end
  end

  # Returns the param to use in a find command for objects with a
  # possible cross-db sort
  def cross_database_order(order, direction, sort_methods_allowed)
    return &quot;#{ order } #{ direction }&quot; if !cross_database_sort?(order, sort_methods_allowed)
  end

  # Returns true if the given order looks like a cross db sort
  # Allowed_methods should be an array of association objects to
  # methods allowed to be called on them.
  def cross_database_sort?(order, allowed_methods)
    return allowed_methods.include?(order)
  end

  # Performs a sort on the given objects by calling methods rather than
  # using a db lookup.
  def cross_database_sort(objects_to_sort, order, direction, sort_methods_allowed)
    if cross_database_sort?(order, sort_methods_allowed)
      methods = order.split(&quot;.&quot;)
      association_name, method = order.split(&quot;.&quot;)
      objects_to_sort = objects_to_sort.sort_by do |object|
        methods.each do |meth|
          next if object.nil?
          object = object.send(meth)
        end
        &quot;#{ object }&quot;
      end
      objects_to_sort.reverse! if direction == &quot;desc&quot;
    end

    return objects_to_sort
  end

  private

  # ActionMailer views don't have access to the request, so we need
  # to set these variables manually.
  def setup_host_for_mail
    ActionMailer::Base.default_url_options[:host] = request.host_with_port
  end

  def logout
    current_user_session.destroy if current_user_session
  end

  def current_user_session
    return @current_user_session if defined?(@current_user_session)
    @current_user_session = UserSession.find
  end

  def current_user
    return @current_user if defined?(@current_user)
    @current_user = current_user_session &amp;&amp; current_user_session.user
  end

  def require_user
    unless current_user
      store_location
      flash[:notice] = &quot;You must be logged in to access this page&quot;
      redirect_to new_user_session_url
      return false
    end
  end

  def require_no_user
    if current_user
      store_location
      flash[:notice] = &quot;You must be logged out to access this page&quot;
      redirect_to &quot;/&quot;
      return false
    end
  end

  def store_location
    session[:return_to] = request.request_uri
  end

  def redirect_back_or_default(default)
    redirect_to(session[:return_to] || default)
    session[:return_to] = nil
  end
end
</pre>
<p>Worth noting the &#8220;ss&#8221; in user_methodss is not a mistake. Because of the way Comatose handles the string/symbol you pass in it wouldn&#8217;t render :user_methods but instead looked for :users_methods which was incorrect so this was our little hack to get around that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/08/comatose-authlogic-and-fckeditor/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Adding your own login method to Authlogic</title>
		<link>http://www.sentia.com.au/2009/06/adding-your-own-login-method-to-authlogic/</link>
		<comments>http://www.sentia.com.au/2009/06/adding-your-own-login-method-to-authlogic/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 02:51:39 +0000</pubDate>
		<dc:creator>Michael Cindric</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[authlogic]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://sentia.com.au/?p=294</guid>
		<description><![CDATA[So on a new project we are working on we have a need for a user to be able to login via either their &#8220;Login&#8221; or &#8220;Mobile&#8221; number. Now we are using the Authlogic gem which is a great gem and comes with all default methods for login etc and allows you to customise this [...]]]></description>
			<content:encoded><![CDATA[<p>So on a new project we are working on we have a need for a user to be able to login via either their &#8220;Login&#8221; or &#8220;Mobile&#8221; number. Now we are using the <a href="http://github.com/binarylogic/authlogic/tree/master">Authlogic</a> gem which is a great gem and comes with all default methods for login etc and allows you to customise this very easily.</p>
<p>So firstly you need to add the following to your UserSession model. What this does is overwrite the default login method with the one we are defining below called &#8220;find_by_username_or_mobile&#8221;.</p>
<pre class="brush: ruby;">
class UserSession &lt; Authlogic::Session::Base
  find_by_login_method :find_by_username_or_mobile
end
</pre>
<p>Then in your user model its as simply as creating the class method for login. Now of course the password is still apart of the login process but we only wanted to allow users to either login via their login or mobile so no need to change the password methods.</p>
<pre class="brush: ruby;">
class User &lt; ActiveRecord::Base
  def self.find_by_username_or_mobile(login)
    find_by_login(login) || find_by_mobile(login)
  end
end
</pre>
<p>So give it a try and let us know how you go hope this helps</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sentia.com.au/2009/06/adding-your-own-login-method-to-authlogic/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
