<?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>Brian Wigginton &#187; Rails</title>
	<atom:link href="http://www.bwigg.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bwigg.com</link>
	<description>Lab and Nerdery</description>
	<lastBuildDate>Fri, 03 Feb 2012 04:15:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Paperclip &#8211; Customizing Paths and URLs</title>
		<link>http://www.bwigg.com/2009/10/paperclip-customizing-paths-and-urls/</link>
		<comments>http://www.bwigg.com/2009/10/paperclip-customizing-paths-and-urls/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 23:08:35 +0000</pubDate>
		<dc:creator>bawigga</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.bwigg.com/?p=64</guid>
		<description><![CDATA[To customize the paths and urls of paperclip objects in your rails app you need to modify both the :path and :url options for  has_attached_file in your models. Here's an example... class SomeModel &#60; ActiveRecord::Base &#160; has_attached_file :image_one, :path =&#62; &#34;public/system/:class/:id/:filename&#34;, :url =&#62; &#34;/system/:class/:id/:basename.:extension&#34; &#160; has_attached_file :image_two, :path =&#62; &#34;public/system/:class/:id/:filename&#34;, :url =&#62; &#34;/system/:class/:id/:basename.:extension&#34; end By [...]]]></description>
			<content:encoded><![CDATA[<p>To customize the paths and urls of paperclip objects in your rails app you need to modify both the :path and :url options for  has_attached_file in your models. Here's an example...<br />
<code> </code></p>
<p><code></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> SomeModel <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
&nbsp;
  has_attached_file <span style="color:#ff3333; font-weight:bold;">:image_one</span>,
    <span style="color:#ff3333; font-weight:bold;">:path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;public/system/:class/:id/:filename&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/system/:class/:id/:basename.:extension&quot;</span>
&nbsp;
  has_attached_file <span style="color:#ff3333; font-weight:bold;">:image_two</span>,
    <span style="color:#ff3333; font-weight:bold;">:path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;public/system/:class/:id/:filename&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/system/:class/:id/:basename.:extension&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p></code><br />
By default Paperclip will store your files in <code>/system/:attachment/:id/:style/:filename</code>. By passing the <code>:path</code> and <code>:url</code> options to the has_attached_file method in your model you can change where the uploaded files will be stored as well as where they can be accessed. The <code>:path</code> is the directory in your application where your files will be stored. The <code>:url</code> is the url that users will use to render the image.</p>
<p>Paperclip Resources</p>
<ul>
<li>Paperclip RDoc - <a title="Paperclip RDoc" href="http://dev.thoughtbot.com/paperclip/" target="_blank">http://dev.thoughtbot.com/paperclip/</a></li>
<li>Paperclip Railscasts - <a title="Paperclip Railscasts" href="http://railscasts.com/episodes/134-paperclip">http://railscasts.com/episodes/134-paperclip</a></li>
<li>Jim Neath - Paperclip: Attaching Files in Rails - <a title="Paperclip: Attaching Files in Rails" href="http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails/">http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bwigg.com/2009/10/paperclip-customizing-paths-and-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

