<?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>Admoo Labs &#187; Ruby on Rails</title>
	<atom:link href="http://blog.admoolabs.com/category/webdev/ror/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.admoolabs.com</link>
	<description>Bringing fun back to the web.</description>
	<lastBuildDate>Sun, 07 Mar 2010 13:45:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JRuby, WAR, and Paperclip</title>
		<link>http://blog.admoolabs.com/jruby-war-and-paperclip/</link>
		<comments>http://blog.admoolabs.com/jruby-war-and-paperclip/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 06:42:56 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[paperclip]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=181</guid>
		<description><![CDATA[If you deploy a jruby on rails application as a war file, the file structure is different from a normal rails application.

&#124;-- 404.html
&#124;-- 422.html
&#124;-- 500.html
&#124;-- WEB-INF
&#124;   &#124;-- app
&#124;   &#124;-- config
&#124;   &#124;-- gems
&#124;   &#124;-- lib
&#124;   &#124;-- log
&#124;   &#124;-- tmp
&#124;   &#124;-- vendor
&#124;  [...]]]></description>
			<content:encoded><![CDATA[<p>If you deploy a jruby on rails application as a war file, the file structure is different from a normal rails application.</p>
<pre class="brush: bash; light: true;">
|-- 404.html
|-- 422.html
|-- 500.html
|-- WEB-INF
|   |-- app
|   |-- config
|   |-- gems
|   |-- lib
|   |-- log
|   |-- tmp
|   |-- vendor
|   `-- web.xml
|-- favicon.ico
|-- images
|   `-- rails.png
|-- index.html
|-- javascripts
|   `-- application.js
|-- robots.txt
|-- stylesheets
|-- system
</pre>
<p>The rails directories are under WEB-INF while the files and directories normally on public/ are on the root directory of the j2ee web app. In glassfish, the root of a rails app named &#8216;labs&#8217; is $GLASSFISH_HOME/domains/domain1/applications/j2ee-modules/labs.</p>
<p>Since the &#8216;public&#8217; directory is not under RAILS_ROOT, you shouldn&#8217;t be using RAILS_ROOT/public when saving files. Instead, use Rails.public_path. Paperclip saves files on &#8220;:rails_root/public/system/:attachment/:id/:style/:filename&#8221; by default. You can add the :path option to change this.</p>
<pre class="brush: ruby; light: true;">
has_attached_file :image, :styles =&gt; { :square =&gt; &quot;48x48#&quot; }, :path =&gt; &quot;#{Rails.public_path}/system/:attachment/:id/:style/:filename&quot;
</pre>
<p>The uploaded files should now be saved on the correct directory.</p>
<p>While this works, it&#8217;s probably not a good idea to save uploaded files on the j2ee-modules/ directory. When you undeploy the &#8216;labs&#8217; app on glassfish, it will remove the &#8216;labs&#8217; directory on j2ee-modules which includes all the uploaded files.</p>
<p>We can symlink labs/system to a directory outside of the glassfish directory. We can also use a different directory for paperclip which doesn&#8217;t use Rails.public_path or Rails.root. (I haven&#8217;t tested both.)</p>
<p>This is only an issue when deploying your jruby apps as a war file. If you&#8217;re using the glassfish gem, you don&#8217;t change the file structure at all. You just run jruby -S glassfish. If you&#8217;re using directory-based deployment on glassfish, undeploying the app doesn&#8217;t remove the directory. </p>
<p>Where are you saving the uploaded files? Let me know in the comments if you have other suggestions. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/jruby-war-and-paperclip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JRuby and the Glassfish Gem</title>
		<link>http://blog.admoolabs.com/jruby-glassfish-ge/</link>
		<comments>http://blog.admoolabs.com/jruby-glassfish-ge/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 13:23:14 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=169</guid>
		<description><![CDATA[The glassfish gem is another way to run a rails application in jruby. Before glassfish, I was using jruby script/server.
Using glassfish is simple. Install the gem and run jruby -S glassfish. However, I got a &#8220;missing gem&#8221; error.

$ sudo jgem install glassfish
Successfully installed glassfish-1.0.2-universal-java
1 gem installed

$ jruby -S glassfish
Starting GlassFish server at: 0.0.0.0:3000 in development [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://glassfishgem.rubyforge.org/">glassfish gem</a> is another way to run a rails application in jruby. Before glassfish, I was using jruby script/server.</p>
<p>Using glassfish is simple. Install the gem and run jruby -S glassfish. However, I got a &#8220;missing gem&#8221; error.</p>
<pre class="brush: bash; light: true;">
$ sudo jgem install glassfish
Successfully installed glassfish-1.0.2-universal-java
1 gem installed

$ jruby -S glassfish
Starting GlassFish server at: 0.0.0.0:3000 in development environment...
Writing log messages to: /Users/crigor/labs/log/development.log.
Press Ctrl+C to stop.

Missing the Rails 2.3.4 gem. Please `gem install -v=2.3.4 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
</pre>
<p>rails 2.3.4 is installed. In fact, jruby script/server works</p>
<pre class="brush: bash; light: true;">
$ jruby script/server
=&gt; Booting Mongrel
=&gt; Rails 2.3.4 application starting on http://0.0.0.0:3000
=&gt; Call with -d to detach
=&gt; Ctrl-C to shutdown server
</pre>
<p>I checked log/development.log and found an error on the run method on config/boot.rb.  </p>
<pre class="brush: plain; light: true;">
INFO: JRuby version is: 1.4.0
Feb 21, 2010 8:45:12 PM com.sun.grizzly.jruby.rack.RackApplicationPoolFactory getRackApplocationPool
SEVERE: exit
	from /Users/crigor/admoolabs/labs/config/boot.rb:38:in `run'
	from /Users/crigor/admoolabs/labs/config/boot.rb:11:in `boot!'
	from /Users/crigor/admoolabs/labs/config/boot.rb:110
	from /Users/crigor/admoolabs/labs/config/boot.rb:31:in `require'
	from /opt/local/share/java/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /Users/crigor/admoolabs/labs/config/environment.rb:7
	from /Users/crigor/admoolabs/labs/config/environment.rb:31:in `require'
	from /opt/local/share/java/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/rack/adapter/rails.rb:98:in `load_application'
	from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/rack/adapter/rails.rb:75:in `initialize'
	from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/jruby/rack/rails.rb:25:in `new'
	from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/glassfish-1.0.2-universal-java/lib/jruby/rack/rails.rb:25:in `new'
	from &lt;script&gt;:1
</pre>
<p>gem &#8216;rails&#8217;, version raised an error, thus the message &#8220;Missing the Rails 2.3.4 gem&#8221;. I&#8217;m sure that the gem is installed and jruby script/server works, so I inspected the error.</p>
<pre class="brush: plain; light: true;">
can't activate rack (~&gt; 1.0.0, runtime) for [&quot;actionpack-2.3.4&quot;, &quot;rails-2.3.4&quot;], already activated rack-1.1.0 for [&quot;glassfish-1.0.2-universal-java&quot;]
</pre>
<p>Look at that, it&#8217;s the familiar rubygems dependency problem. glassfish requires rack >= 0.4.0 but rubygems will activate the newest gem available which is version 1.1.0. rails 2.3.4 requires rack ~> 1.0.0, thus the conflict. This is the problem that bundler is trying to solve. Check my other <a href="http://blog.admoolabs.com/bundler-rubygems-again/">post</a> or the bundler <a href="http://github.com/carlhuda/bundler#readme">readme</a> for more details on the dependency problem. </p>
<p>The easiest way to get glassfish running is by removing rack 1.1.0. I&#8217;m not using it anyway. </p>
<pre class="brush: bash; light: true;">
$ sudo jgem uninstall rack

Select gem to uninstall:
 1. rack-1.0.1
 2. rack-1.1.0
 3. All versions
&gt; 2
Successfully uninstalled rack-1.1.0

$ jruby -S glassfish
Starting GlassFish server at: 0.0.0.0:3000 in development environment...
Writing log messages to: /Users/crigor/admoolabs/labs/log/development.log.
Press Ctrl+C to stop.
</pre>
<p>Go to localhost:3000, click &#8220;About your application’s environment&#8221; and check development.log</p>
<pre class="brush: plain; light: true;">
Feb 21, 2010 9:03:38 PM sun.reflect.NativeMethodAccessorImpl invoke0
INFO: 

Processing Rails::InfoController#properties (for 0:0:0:0:0:0:0:1%0 at 2010-02-21 21:03:38) [GET]

Feb 21, 2010 9:03:38 PM sun.reflect.NativeMethodAccessorImpl invoke0
INFO:   SQL (28.0ms)   SELECT version FROM schema_migrations

Feb 21, 2010 9:03:38 PM sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Completed in 302ms (View: 57, DB: 28) | 200 OK [http://localhost/rails/info/properties]
</pre>
<p>In the future, I will try bundler or loading the gems myself. I already tried this <a href="http://blog.admoolabs.com/bundler-rubygems-again/">before</a> with ruby 1.8.7 when rails 2.3.5 wasn&#8217;t working with bundler 0.9.4.</p>
<p>Please share in the comments if you have other ways of running your jruby apps. Are you using glassfish or a different java app server?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/jruby-glassfish-ge/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bundler and Rubygems Again</title>
		<link>http://blog.admoolabs.com/bundler-rubygems-again/</link>
		<comments>http://blog.admoolabs.com/bundler-rubygems-again/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 17:18:23 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=165</guid>
		<description><![CDATA[On my previous post, I showed you how to use bundler with rails 2.3.5. Bundler is used to install the gems, and rubygems is used to load the gems. Bundler as of version 0.9.4 doesn&#8217;t work with rails 2.3.5.
Since rubygems is used to load the gems, you might still encounter dependency resolution issues. This situation [...]]]></description>
			<content:encoded><![CDATA[<p>On my <a href="http://blog.admoolabs.com/using-bundler-0-9-4-with-rails-2-3-5/">previous post</a>, I showed you how to use bundler with rails 2.3.5. Bundler is used to install the gems, and rubygems is used to load the gems. Bundler as of version 0.9.4 doesn&#8217;t work with rails 2.3.5.</p>
<p>Since rubygems is used to load the gems, you might still encounter dependency resolution issues. This situation is described in the <a href="http://github.com/carlhuda/bundler#readme">readme</a> of bundler. Let&#8217;s say you have the following gems</p>
<p>actionmailer 2.3.4<br />
activemerchant 1.5.0<br />
activesupport 2.3.5, 2.3.4</p>
<p>Activemerchant needs activesupport >= 2.3.2. When you require activemerchant, it will activate the latest version that meets that requirement which is 2.3.5. Actionmailer on the other hand needs activesupport = 2.3.4. When rubygems tries to activate activesupport 2.3.4, it will raise an error.</p>
<pre class="brush: ruby; light: true;">
$ irb
irb(main):001:0&gt; require 'rubygems'
=&gt; true
irb(main):002:0&gt; gem 'activemerchant'
=&gt; true
irb(main):003:0&gt; gem 'actionmailer'
Gem::LoadError: can't activate activesupport (= 2.3.4, runtime) for [&quot;actionpack-2.3.4&quot;, &quot;actionmailer-2.3.4&quot;], already activated activesupport-2.3.5 for [&quot;activemerchant-1.5.0&quot;]
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:280:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:296:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `each'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:296:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `each'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:68:in `gem'
	from (irb):3
irb(main):004:0&gt;
</pre>
<p>Even if bundler installs the correct versions to vendor/bundler_gems, the presence of activesupport 2.3.5 in the system will cause an error. Another solution I tried is managing the load path by hand.</p>
<p>On config/preinitializer.rb</p>
<pre class="brush: ruby; light: true;">
bundler_gems = File.expand_path('../../vendor/bundler_gems/gems', __FILE__)
if File.exist?(bundler_gems)
  Dir[&quot;#{bundler_gems}/*/lib&quot;].each { |path| $:.unshift(path) }
end
</pre>
<p>This works if you use require instead of gem.</p>
<pre class="brush: ruby; light: true;">
$ irb
irb(main):001:0&gt; bundler_gems = File.expand_path('/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems')
=&gt; &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems&quot;
irb(main):002:0&gt; if File.exist?(bundler_gems)
irb(main):003:1&gt;   Dir[&quot;#{bundler_gems}/*/lib&quot;].each { |path| $:.unshift(path) }
irb(main):004:1&gt; end
=&gt; [&quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/actionmailer-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/actionpack-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activemerchant-1.5.0/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activerecord-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activeresource-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activesupport-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/builder-2.1.2/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/bundler-0.9.5/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/rack-1.0.1/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/rails-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/rake-0.8.7/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/sqlite3-ruby-1.2.5/lib&quot;]
irb(main):005:0&gt; require 'rubygems'
=&gt; true
irb(main):006:0&gt; require 'active_merchant'
=&gt; true
irb(main):007:0&gt; require 'action_mailer'
=&gt; [&quot;MailHelper&quot;, &quot;Text&quot;, &quot;ActionMailer&quot;]
</pre>
<pre class="brush: ruby; light: true;">
$ irb
irb(main):001:0&gt; bundler_gems = File.expand_path('/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems')
=&gt; &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems&quot;
irb(main):002:0&gt; if File.exist?(bundler_gems)
irb(main):003:1&gt;   Dir[&quot;#{bundler_gems}/*/lib&quot;].each { |path| $:.unshift(path) }
irb(main):004:1&gt; end
=&gt; [&quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/actionmailer-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/actionpack-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activemerchant-1.5.0/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activerecord-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activeresource-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/activesupport-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/builder-2.1.2/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/bundler-0.9.5/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/rack-1.0.1/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/rails-2.3.4/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/rake-0.8.7/lib&quot;, &quot;/Users/crigor/admoolabs/labs/vendor/bundler_gems/gems/sqlite3-ruby-1.2.5/lib&quot;]
irb(main):005:0&gt; require 'rubygems'
=&gt; true
irb(main):006:0&gt; gem 'activemerchant'
=&gt; true
irb(main):007:0&gt; gem 'actionmailer'
Gem::LoadError: can't activate activesupport (= 2.3.4, runtime) for [&quot;actionpack-2.3.4&quot;, &quot;actionmailer-2.3.4&quot;], already activated activesupport-2.3.5 for [&quot;activemerchant-1.5.0&quot;]
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:280:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:296:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `each'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:296:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `each'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:295:in `activate'
	from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:68:in `gem'
	from (irb):7
	from /opt/local/lib/ruby/1.8/i686-darwin10/rbconfig.rb:132
</pre>
<p>Require works because I added the lib/ directories to the load path. If a file exists on the load path, require will not activate the gem. It will just load the file. If gems use gem &#8216;activesupport&#8217; before require &#8216;active_support&#8217;, then we&#8217;ll be in trouble. This is not the ideal solution I&#8217;m looking for but it&#8217;s close. On my next post, I&#8217;ll discuss using &#8216;fake&#8217; rubygems.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/bundler-rubygems-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Bundler 0.9.4 with Rails 2.3.5</title>
		<link>http://blog.admoolabs.com/using-bundler-0-9-4-with-rails-2-3-5/</link>
		<comments>http://blog.admoolabs.com/using-bundler-0-9-4-with-rails-2-3-5/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 14:12:44 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=160</guid>
		<description><![CDATA[Bundler works well with rails 3 beta but it doesn&#8217;t work with rails 2.3.5 yet. Here&#8217;s a simple way to use the gems installed by bundler.
Let&#8217;s create a rails app named labs.

$ rails labs
$ cd labs
$ ./script/console
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails [...]]]></description>
			<content:encoded><![CDATA[<p>Bundler works well with rails 3 beta but it doesn&#8217;t work with rails 2.3.5 yet. Here&#8217;s a simple way to use the gems installed by bundler.</p>
<p>Let&#8217;s create a rails app named labs.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ rails labs
$ cd labs
$ ./script/console
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed
</pre>
<p>As you can see, the rails 2.3.5 gem is missing. We will use bundler to install the gems to vendor/bundler_gems.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ vi Gemfile
</pre>
<pre class="brush: ruby; auto-links: false; light: true;">
source &quot;http://gemcutter.org&quot;
gem &quot;rails&quot;, &quot;2.3.5&quot;
gem &quot;sqlite3-ruby&quot;, :require =&gt; &quot;sqlite3&quot;
</pre>
<pre class="brush: bash; auto-links: false; light: true;">
$ bundle install vendor/bundler_gems
Fetching source index from http://gemcutter.org
Resolving dependencies
Installing actionmailer (2.3.5) from rubygems repository at http://gemcutter.org
Installing actionpack (2.3.5) from rubygems repository at http://gemcutter.org
Installing activerecord (2.3.5) from rubygems repository at http://gemcutter.org
Installing activeresource (2.3.5) from rubygems repository at http://gemcutter.org
Installing activesupport (2.3.5) from rubygems repository at http://gemcutter.org
Installing rack (1.0.1) from rubygems repository at http://gemcutter.org
Installing rails (2.3.5) from rubygems repository at http://gemcutter.org
Installing rake (0.8.7) from rubygems repository at http://gemcutter.org
Installing sqlite3-ruby (1.2.5) from rubygems repository at http://gemcutter.org with native extensions
Your bundle is complete!
</pre>
<pre class="brush: bash; auto-links: false; light: true;">
$ ./script/console
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed
</pre>
<p>The gem is still missing. Of course, the app doesn&#8217;t know where the gems are located.</p>
<p>We used bundler to install the gems, and in the future, we will use bundler to load the gems. Until then, we will use rubygems to load the gems. Create config/preinitializer.rb and set GEM_HOME.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ vi config/preinitializer.rb
</pre>
<pre class="brush: ruby; auto-links: false; light: true;">
ENV[&quot;GEM_HOME&quot;] = File.expand_path('../../vendor/bundler_gems', __FILE__)
</pre>
<pre class="brush: bash; auto-links: false; light: true;">
$ ./script/console
Loading development environment (Rails 2.3.5)
&gt;&gt; Rails.version
=&gt; &quot;2.3.5&quot;
&gt;&gt; Rack.version
=&gt; &quot;1.0&quot;
&gt;&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/using-bundler-0-9-4-with-rails-2-3-5/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How I Use Bundler</title>
		<link>http://blog.admoolabs.com/how-i-use-bundler/</link>
		<comments>http://blog.admoolabs.com/how-i-use-bundler/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 06:48:15 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=149</guid>
		<description><![CDATA[You probably heard that rails 3 beta is out and you want to try it. The instructions tell you to install the gems

gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
gem install rails --pre

Here, I&#8217;ll give you an alternative to installing rails 3 beta using bundler 0.9.3. This is for [...]]]></description>
			<content:encoded><![CDATA[<p>You probably heard that rails 3 beta is out and you want to try it. The instructions tell you to install the gems</p>
<pre class="brush: bash; auto-links: false; light: true;">
gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
gem install rails --pre
</pre>
<p>Here, I&#8217;ll give you an alternative to installing rails 3 beta using bundler 0.9.3. This is for those who don&#8217;t want to mix the rails 3 gems with their system gems, or who don&#8217;t want to use rubygems. Well you still need rubygems to install bundler.</p>
<pre class="brush: bash; auto-links: false; light: true;">
gem install bundler
</pre>
<p>After that, we create a gemfile on a directory that I&#8217;ll name &#8216;envs&#8217;.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ mkdir envs
$ cd envs
$ vi Gemfile
</pre>
<pre class="brush: ruby; auto-links: false; light: true;">
source &quot;http://gemcutter.org&quot;
gem &quot;rails&quot;, &quot;3.0.0.beta&quot;
</pre>
<pre class="brush: bash; auto-links: false; light: true;">
$ bundle install r3b
Resolving dependencies
Installing abstract (1.0.0) from rubygems repository at http://gemcutter.org
Installing actionmailer (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing actionpack (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing activemodel (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing activerecord (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing activeresource (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing activesupport (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing arel (0.2.1) from rubygems repository at http://gemcutter.org
Installing builder (2.1.2) from rubygems repository at http://gemcutter.org
Installing bundler (0.9.3) from rubygems repository at http://gemcutter.org
Installing erubis (2.6.5) from rubygems repository at http://gemcutter.org
Installing i18n (0.3.3) from rubygems repository at http://gemcutter.org
Installing mail (2.1.2) from rubygems repository at http://gemcutter.org
Installing memcache-client (1.7.8) from rubygems repository at http://gemcutter.org
Installing mime-types (1.16) from rubygems repository at http://gemcutter.org
Installing rack (1.1.0) from rubygems repository at http://gemcutter.org
Installing rack-mount (0.4.7) from rubygems repository at http://gemcutter.org
Installing rack-test (0.5.3) from rubygems repository at http://gemcutter.org
Installing rails (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing railties (3.0.0.beta) from rubygems repository at http://gemcutter.org
Installing rake (0.8.7) from rubygems repository at http://gemcutter.org
Installing text-format (1.0.0) from rubygems repository at http://gemcutter.org
Installing text-hyphen (1.0.0) from rubygems repository at http://gemcutter.org
Installing thor (0.13.0) from rubygems repository at http://gemcutter.org
Installing tzinfo (0.3.16) from rubygems repository at http://gemcutter.org
Your bundle is complete!
</pre>
<pre class="brush: bash; auto-links: false; light: true;">
$ bundle show
Gems included by the bundle:
* abstract (1.0.0)
* actionmailer (3.0.0.beta)
* actionpack (3.0.0.beta)
* activemodel (3.0.0.beta)
* activerecord (3.0.0.beta)
* activeresource (3.0.0.beta)
* activesupport (3.0.0.beta)
* arel (0.2.1)
* builder (2.1.2)
* bundler (0.9.3)
* erubis (2.6.5)
* i18n (0.3.3)
* mail (2.1.2)
* memcache-client (1.7.8)
* mime-types (1.16)
* rack (1.1.0)
* rack-mount (0.4.7)
* rack-test (0.5.3)
* rails (3.0.0.beta)
* railties (3.0.0.beta)
* rake (0.8.7)
* text-format (1.0.0)
* text-hyphen (1.0.0)
* thor (0.13.0)
* tzinfo (0.3.16)
</pre>
<p>I like to create my rails apps on a separate directory outside of envs. We need to specify the location of the Gemfile.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ cd ..
$ bundle show
The default Gemfile was not found
</pre>
<p>We need to specify the location of the Gemfile.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ export BUNDLE_GEMFILE=&quot;/Users/crigor/admoolabs/envs/Gemfile&quot;
$ bundle show
Gems included by the bundle:
* abstract (1.0.0)
* actionmailer (3.0.0.beta)
* actionpack (3.0.0.beta)
...
</pre>
<p>You can now run the rails command using bundle exec.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ rails -v
Rails 2.3.4
$ bundle exec rails -v
Rails 3.0.0.beta
</pre>
<p>Let&#8217;s create the rails app named labsapp.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ bundle exec rails labsapp
      create
      create  README
      create  .gitignore
      create  Rakefile
      create  config.ru
      create  Gemfile
      create  app
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/models
      create  app/views/layouts
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookie_verification_secret.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/application.js
      create  public/javascripts/controls.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/effects.js
      create  public/javascripts/prototype.js
      create  public/javascripts/rails.js
      create  script
      create  script/rails
      create  test
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/unit
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
</pre>
<p>Let&#8217;s run the console.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ cd labsapp
$ ./script/rails c
Loading development environment (Rails 3.0.0.beta)
irb(main):001:0&gt; Rails.version
=&gt; &quot;3.0.0.beta&quot;
irb(main):002:0&gt; Rack.version
=&gt; &quot;1.1&quot;
</pre>
<p>You now have the rails 3 gems separate from rails 2.x gems. Only the rails 2.x gems are installed on the system.</p>
<pre class="brush: bash; auto-links: false; light: true;">
$ gem list rails
rails (2.3.4, 2.3.2, 2.2.2, 2.1.1, 2.1.0)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/how-i-use-bundler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>uninitialized constant PGconn</title>
		<link>http://blog.admoolabs.com/uninitialized-constant-activerecord-connectionadapters-postgresqladapter-pgconn/</link>
		<comments>http://blog.admoolabs.com/uninitialized-constant-activerecord-connectionadapters-postgresqladapter-pgconn/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 15:36:09 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=143</guid>
		<description><![CDATA[I&#8217;m successfully using Postgres for development. My stack includes ruby 1.8.7, rails 2.3.4, and pg 0.8.0. One day, I get an error

NameError: uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn

I didn&#8217;t update Postgres or the pg gem so I don&#8217;t see a reason for it to stop working. Then I remember that I installed jruby and installed the activerecord adapater. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m successfully using Postgres for development. My stack includes ruby 1.8.7, rails 2.3.4, and pg 0.8.0. One day, I get an error</p>
<pre class="brush: plain; light: true;">
NameError: uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn
</pre>
<p>I didn&#8217;t update Postgres or the pg gem so I don&#8217;t see a reason for it to stop working. Then I remember that I installed jruby and installed the activerecord adapater. Instead of using jgem install, I used gem install. This installed the gems (activerecord-jdbc-adapter, activerecord-jdbcmysql-adapter and jdbc-mysql) on my ruby 1.8.7 system. I left the gems installed thinking they wouldn&#8217;t cause any error.</p>
<p>So, if you encounter uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn check if you have the jdbc adapter gems for jruby.</p>
<p>I hope this helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/uninitialized-constant-activerecord-connectionadapters-postgresqladapter-pgconn/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>RailsConf 2009</title>
		<link>http://blog.admoolabs.com/railsconf-2009/</link>
		<comments>http://blog.admoolabs.com/railsconf-2009/#comments</comments>
		<pubDate>Mon, 04 May 2009 00:18:07 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[railsconf]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=94</guid>
		<description><![CDATA[


]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.railsconf.com"><br />
<img src="http://assets.en.oreilly.com/1/event/24/rails2009_210x60.jpg" width="210" height="60"  border="0"  alt="RailsConf 2009" title="RailsConf 2009"  /><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/railsconf-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sortable Tables</title>
		<link>http://blog.admoolabs.com/sortable-tables/</link>
		<comments>http://blog.admoolabs.com/sortable-tables/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 04:46:44 +0000</pubDate>
		<dc:creator>Gerald Abrencillo</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=87</guid>
		<description><![CDATA[Rails has a helper function called sortable_element that generates ajax code to allow you to sort lists by dragging and dropping elements. The function defaults to handle lists and if you want to sort tables you should take note of the :tag option.
&#38;lt;%= sortable_element 'my_list',
:url =&#38;gt; { :action =&#38;gt; "order" },     [...]]]></description>
			<content:encoded><![CDATA[<p>Rails has a helper function called sortable_element that generates ajax code to allow you to sort lists by dragging and dropping elements. The function defaults to handle lists and if you want to sort tables you should take note of the :tag option.</p>
<pre><code>&amp;lt;%= sortable_element 'my_list',</code></pre>
<pre style="padding-left:30px;"><code>:url =&amp;gt; { :action =&amp;gt; "order" },       </code></pre>
<pre style="padding-left:30px;"><code>:tag =&amp;gt; 'tr' %&amp;gt;</code></pre>
<p>This should allow you to sort tables and hopefully save you from a big headache.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/sortable-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paperclip</title>
		<link>http://blog.admoolabs.com/paperclip/</link>
		<comments>http://blog.admoolabs.com/paperclip/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 02:55:22 +0000</pubDate>
		<dc:creator>Christopher Rigor</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[paperclip]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=59</guid>
		<description><![CDATA[Paperclip recently made some changes making it more flexible. 
Paperclip is a library for ActiveRecord used for file attachment. The most common use is for uploading images. It can optionally create thumbnails when you upload images. Paperclip requires ImageMagick for resizing images but it doesn&#8217;t require any Ruby libraries like RMagick or MiniMagick.
You can install [...]]]></description>
			<content:encoded><![CDATA[<p>Paperclip <a href="http://giantrobots.thoughtbot.com/2008/12/30/what-good-is-a-flexible-paperclip">recently made some changes</a> making it more flexible. </p>
<p>Paperclip is a library for ActiveRecord used for file attachment. The most common use is for uploading images. It can optionally create thumbnails when you upload images. Paperclip requires ImageMagick for resizing images but it doesn&#8217;t require any Ruby libraries like RMagick or MiniMagick.</p>
<p>You can install paperclip as a gem or as a plugin. The paperclip gem needs right_aws, mocha, and shoulda.<br />
<code>gem install right_aws<br />
gem install mocha<br />
gem install thoughtbot-shoulda --source=http://gems.github.com<br />
gem install thoughtbot-paperclip --source=http://gems.github.com</code></p>
<p>To install the plugin, run <code>./script/plugin install git://github.com/thoughtbot/paperclip.git</code>.</p>
<p>Let&#8217;s say you have a User model and you want to add an avatar. On the users table, you need to add avatar_file_name.</p>
<pre class="brush: ruby;">
class CreateUsers &lt; ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :login
      t.string :avatar_file_name
    end
  end

  def self.down
    drop_table :users
  end
end
</pre>
<p>On user.rb, add has_attached_file</p>
<pre class="brush: ruby;">
class User &lt; ActiveRecord::Base
  has_attached_file :avatar
end
</pre>
<p>You just need to set avatar to an uploaded file and paperclip will handle the rest.  On app/views/users/new.html.erb</p>
<pre class="brush: ruby;">
  &lt;% form_for :user, @user, :url =&gt; users_path, :html =&gt; { :multipart =&gt; true } do |form| %&gt;
    &lt;%= form.text_field :login %&gt; &lt;br /&gt;
    &lt;%= form.file_field :avatar %&gt; &lt;br /&gt;
    &lt;%= submit_tag 'Save' %&gt;
  &lt;% end %&gt;
</pre>
<p>:multipart  => true is needed when uploading files. Then on app/controllers/users_controller.rb</p>
<pre class="brush: ruby;">
  def new
    @user = User.new
  end

  def create
    @user = User.create(params[:user])
  end
</pre>
<p>@user.avatar.url will give you the url of the uploaded image. That&#8217;s all the code you need to use paperclip. There are more options for creating thumbnails, validating the model, and post-processing.</p>
<p>The uploaded files will be saved on RAILS_ROOT/public/system/:attachment/:id/:style/:basename.:extension. On my computer the file is saved on RAILS_ROOT/public/system/avatars/1/original/image.jpg.</p>
<p>As you can see, the default style is original. To add more &#8217;styles&#8217;, </p>
<pre class="brush: ruby;">
class User &lt; ActiveRecord::Base
  has_attached_file :avatar, :styles =&gt; { :medium =&gt; &quot;300x300&gt;&quot;, :thumb =&gt; &quot;100x100&gt;&quot; }
end
</pre>
<p>When you upload the image, paperclip will save the original image, and resize the image to medium and thumb. On RAILS_ROOT/public/system/avatars/2, you will see the directories original, medium and thumb.</p>
<p>To get the medium and thumb images, you will use @user.avatar.url(:medium) and @user.avatar.url(:thumb).</p>
<p>On the users table, you can also add avatar_content_type (string), avatar_file_size (integer), and avatar_updated_at (datetime). These fields will be populated by paperclip automatically.</p>
<p>I will discuss validation and other post-processing options on my next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/paperclip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails for Designers 101 &#8211; Step by Step Version</title>
		<link>http://blog.admoolabs.com/rails-for-designers-101-step-by-step-version/</link>
		<comments>http://blog.admoolabs.com/rails-for-designers-101-step-by-step-version/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 11:39:51 +0000</pubDate>
		<dc:creator>Eumir Gaspar</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://blog.admoolabs.com/?p=40</guid>
		<description><![CDATA[This is more of a &#8216;tutorialized&#8217; version of my previous post. Here, I&#8217;ll be sharing how I made my &#8216;portfolio/haml converter&#8217; rails application, since I unfortunately assumed that anyone reading that post also knew what I knew. This time though, I&#8217;ll be assuming nothing, just that you are a designer and you just want to [...]]]></description>
			<content:encoded><![CDATA[<p>This is more of a &#8216;tutorialized&#8217; version of my previous post. Here, I&#8217;ll be sharing how I made my &#8216;portfolio/haml converter&#8217; rails application, since I unfortunately assumed that anyone reading that post also knew what I knew. This time though, I&#8217;ll be assuming nothing, just that you are a designer and you just want to try coding in Haml for a change(good for you!) even if you don&#8217;t know squat about rails.</p>
<p>For starters, if you don&#8217;t have Rails yet, I suggest either installing Rails the hardcore way, or take the easy way out like I did: just download <a href="http://rubyforge.org/projects/instantrails/">InstantRails</a>. Okay, after you&#8217;re done with that part(I&#8217;ll be assuming you also took the easy way out) just unzip that into your root directory(I&#8217;m using Windows *gasp* so mine is located at C:/Instantrails/)</p>
<p>Now, all you have to do is bring up a command line(windows key + r, then type cmd), go to your Instantrails folder(type &#8216;C:/Instantrails/&#8217;) then type &#8216;use_ruby&#8217;. You&#8217;ll know you did the right thing when the directory changes to C:/Instantrails/rails_apps(just realized it&#8217;ll be better with screenshots&#8230;but I&#8217;ll do that later)</p>
<p>OKay, next in line is installing haml. Ready? Just type:</p>
<p><code>gem install haml</code></p>
<p>That&#8217;s it! Haml should be automatically downloading now. As you wait for that one, you can open up a new command line, go to your IR(due to laziness I&#8217;ll be calling Instantrails IR from now on) folder again, type use_ruby again and then type</p>
<p><code>rails myhamlizedportfolio</code></p>
<p>Actually you can name it anything you want. Doesn&#8217;t really matter(I sugest you pick a short name though). This will effectively create a blank rails app for you. And by that I mean it will create a folder named myhamlizedportfolio in your rails_app folder, complete with all the folders needed for a blank rails app. Next would be to install haml as a plugin for your portfolio app(you should still be in C:/Instantrails/rails_app when you do this):</p>
<p><code>haml --rails myhamlizedportfolio</code></p>
<p>Easy, right? Next, you just have to tell rails that you won&#8217;t be needing any database of sorts. So goand open the myhamlizedportfolio/config folder. Open environment.rb(with your favorite text editor &#8211; notepad) and look for the following lines</p>
<pre class="brush: ruby;"># Skip frameworks you're not going to use. To use Rails without a database  
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]</pre>
<p>Just take out the &#8216;#&#8217; of the third line like so:</p>
<pre class="brush: ruby;"># Skip frameworks you're not going to use. To use Rails without a database
# you must remove the Active Record framework.
config.frameworks -= [ :active_record, :active_resource, :action_mailer ]</pre>
<p>Save this and close the file. Delete database.yml in that same folder by the way &#8211; you won&#8217;t be needing that. Next up is to fix your routes(if you want to understand what you&#8217;re actually doing, I suggest learning basic rails first like a good citizen, but if you can&#8217;t be bothered, then just follow these steps and believe it will work <img src='http://blog.admoolabs.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ). Open up routes.rb with notepad(it&#8217;s still in the config folder) and add this line right after the first line like so:</p>
<pre class="brush: ruby;">
ActionController::Routing::Routes.draw do |map|
map.connect 'projects/:id', :controller =&gt; 'projects', :action =&gt; 'index'
 </pre>
<p>That just basically means that to access your projects all you have to do is go to http://localhost:3000/projects/projectnamehere. More on that later. For now, save and exit again and you&#8217;re done with the config folder. We&#8217;re almost there! </p>
<p>Now go back to your command line and while in your project directory(in our case, myhamlizedportfolio) and type</p>
<p><code>ruby script/generate controller projects</code></p>
<p>This will generate some files but what we really want to focus on is the newly generated projects_controller.rb located in myhamlizedportfolio/app/controllers. Open this file up with notepad, as usual, and well, just replace all the code there with this:</p>
<pre class="brush: ruby;">
class ProjectsController &lt; ApplicationController
def index
render :action =&gt; &quot;#{params[:id]}/index&quot;
end
end
</pre>
<p>Don&#8217;t worry if you don&#8217;t understand. That&#8217;s just a &#8216;continuation&#8217; of what we did with routes.rb, basically telling our app that going to http://localhost:3000/projects/projectnamehere means it should render the page with the same name located in your views(again, more on that soon).</p>
<p>Actually you&#8217;re done setting up. You can now start coding with Haml. To start, let&#8217;s make a design project named RedHelloWorld. Go to your views folder(myhamlizedportfolio/app/views) and make a new directory named RedHelloWorld. Open up notepad again and type these:</p>
<pre class="brush: ruby;">
!!!

%html{:xmlns =&gt; &quot;http://www.w3.org/1999/xhtml&quot;, &quot;xml:lang&quot; =&gt; &quot;en&quot;, :lang =&gt; &quot;en&quot;}
  = yield :layout
</pre>
<p>If you have reviewed <a href="http://haml.hamptoncatlin.com/">Haml</a>, that just basically creates the basic headers for your html page. Save that as application.haml and save it in the views/layouts folder(also delete application.html there if it exists). Create a new document yet again and type the following:</p>
<pre class="brush: ruby;">
%head
  %meta{&quot;http-equiv&quot; =&gt; &quot;content-type&quot;, :content =&gt; &quot;text/html;charset=UTF-8&quot;}
  %title hamlicious home!
  = stylesheet_link_tag 'demo'

  %body
    %h1.red HELLO WORLD!
</pre>
<p>Just by looking at the code, you&#8217;ll already know that Haml really makes things easier for you. A lot of time is saved since you won&#8217;t be needing to type the appropriate closing tags for each div, or other html tag out there. Save that file as index.haml and save it in views/RedHelloWorld (yup, create a folder with that name).</p>
<p>Next up, is your sass(css) file. Open up a new text file again and type:</p>
<pre class="brush: ruby;">
.red
  :color #ff0000
</pre>
<p>Save that as demo.sass and save it in myhamlizedportfolio/public/stylesheets/sass/(you&#8217;ll have to create a sass folder). While you&#8217;re at it, also delete the index.html in your public/ folder. And now all you have to do is run and test your app! Go to your command line(yet again) and after use_ruby and going to your project directory, just type </p>
<p><code>ruby script/server</code></p>
<p>Wait til ou see the lines:</p>
<p>** Mongrel available at 0.0.0.0:3000<br />
** Use CTRL-C to stop.</p>
<p>And that&#8217;s it. You can now access your demo by opening up your browser and going to http://localhost:3000/projects/RedHelloWorld</p>
<p>Hopefully that&#8217;ll work. Any problems, leave a comment <img src='http://blog.admoolabs.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  Oh and before I forget, if you need the html and css files(like I do &#8211; I just like coding in Haml/Sass) just view the page, view the source and copy paste it in a blank document and save it as .html(in another directory of course). Get the .css file that will be generated in myhamlizedportfolio/public/stylesheets/ and use that for the css file of your project. Enjoy!</p>
<p>More on customizing this app sometime in the future. (namely how to make a &#8220;homepage&#8221; where you have a list of all your hamlized projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.admoolabs.com/rails-for-designers-101-step-by-step-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
