<?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>anycreative</title>
	<atom:link href="http://www.anycreative.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anycreative.net</link>
	<description>株式会社エニークリエイティブ</description>
	<lastBuildDate>Mon, 24 Jan 2011 22:32:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>paperclipで、ローカルにある画像ファイルを登録する。</title>
		<link>http://www.anycreative.net/2011/01/paperclip%e3%81%a7%e3%80%81%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e3%81%ab%e3%81%82%e3%82%8b%e7%94%bb%e5%83%8f%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e7%99%bb%e9%8c%b2%e3%81%99%e3%82%8b%e3%80%82/</link>
		<comments>http://www.anycreative.net/2011/01/paperclip%e3%81%a7%e3%80%81%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e3%81%ab%e3%81%82%e3%82%8b%e7%94%bb%e5%83%8f%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e7%99%bb%e9%8c%b2%e3%81%99%e3%82%8b%e3%80%82/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 22:32:17 +0000</pubDate>
		<dc:creator>伊藤 誠</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.anycreative.net/?p=40</guid>
		<description><![CDATA[ActiveRecordのオブジェクトに、
簡単に画像を添付して登録できるPaperclipというプラグインがあります。
一般的な使い方は、ブラウザのフォームから、画像を送信して画像を登録するのですが、
rails ru [...]]]></description>
			<content:encoded><![CDATA[<p>ActiveRecordのオブジェクトに、<br />
簡単に画像を添付して登録できるPaperclipというプラグインがあります。</p>
<p>一般的な使い方は、ブラウザのフォームから、画像を送信して画像を登録するのですが、<br />
<code>rails runner</code>で動かすスクリプト等でも使いたいので、<br />
ローカルのディスクに保存してあるファイルからの登録をしてみます。</p>
<p>事前に、下記のwikiを参考に、paperclipのインストール、ActiveRecordへのコードの追加を済ませておいてください。<br />
<a href="https://github.com/thoughtbot/paperclip/wiki">paperclip wiki</a><br />
下記の例では、Machineオブジェクトに、imageという名前でpaperclipを設定しています。<br />
<code>class Machine < ActiveRecord::Base<br />
  has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }<br />
end</code></p>
<p>まずは、登録したい画像オブジェクトを、抽出します。<br />
<code>image_file = File.open('abc.jpg')</code></p>
<p>次に、該当するActiveRecordのモデルオブジェクトを抽出します。<br />
<code>item = Item.create</code></p>
<p>そして、最後にファイルオブジェクトを代入します。<br />
<code>item.image = image_file<br />
item.save</code></p>
<p>wikiやソースコードのコメントには、<br />
この使用法は載っていませんでしたが、<br />
無事、オリジナル、ミディアム、サムネールの３種類の画像が登録されました。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anycreative.net/2011/01/paperclip%e3%81%a7%e3%80%81%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e3%81%ab%e3%81%82%e3%82%8b%e7%94%bb%e5%83%8f%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e7%99%bb%e9%8c%b2%e3%81%99%e3%82%8b%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Haml</title>
		<link>http://www.anycreative.net/2010/02/haml/</link>
		<comments>http://www.anycreative.net/2010/02/haml/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 17:57:15 +0000</pubDate>
		<dc:creator>伊藤 誠</dc:creator>
				<category><![CDATA[開発ノート]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.anycreative.net/?p=13</guid>
		<description><![CDATA[Rubyのテンプレートエンジン。
Railsなどでもプラグインとして使用でき、
とてもシンプルにビューの中身を書けます。
まずは、Gemのインストールから。
gem install haml
続いてRailsにプラグイン [...]]]></description>
			<content:encoded><![CDATA[<p>Rubyのテンプレートエンジン。<br />
Railsなどでもプラグインとして使用でき、<br />
とてもシンプルにビューの中身を書けます。</p>
<p>まずは、Gemのインストールから。</p>
<pre class="brush: plain;">gem install haml</pre>
<p>続いてRailsにプラグインを組み込む</p>
<pre class="brush: plain;">haml --rails path/to/rails/app</pre>
<p>で、終了。</p>
<p>あとは、</p>
<pre class="brush: plain;">
!!! XML
%anycreative
  %current
    %time= Time.now.to_s(:db)
</pre>
<p>をindex.html.haml等の名前でビューディレクトリに置き、<br />
表示させると、こうなります。</p>
<pre class="brush: plain;">
&lt;?xml version='1.0' encoding='utf-8' ?&gt;
&lt;anycreative&gt;
  &lt;current&gt;
    &lt;time&gt;2010-02-08 03:16:56&lt;/time&gt;
  &lt;/current&gt;
&lt;/anycreative&gt;
</pre>
<p>公式サイトはこちら。<br />
Haml - <a href="http://haml-lang.com/">http://haml-lang.com/</a></p>
<p>TextMateバンドルは、<a href="http://svn.textmate.org/trunk/Bundles/Ruby%20Haml.tmbundle/">こちら</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anycreative.net/2010/02/haml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ブログ開始のお知らせ</title>
		<link>http://www.anycreative.net/2010/02/firstentry/</link>
		<comments>http://www.anycreative.net/2010/02/firstentry/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 09:48:50 +0000</pubDate>
		<dc:creator>伊藤 誠</dc:creator>
				<category><![CDATA[お知らせ]]></category>
		<category><![CDATA[blog]]></category>

		<guid isPermaLink="false">http://www.anycreative.net/?p=1</guid>
		<description><![CDATA[本日よりブログを開始致しました。
弊社に関するニュースや、開発に関するトピックなどの記事を、発信していきます。
これからもどうぞよろしくお願い致します。
]]></description>
			<content:encoded><![CDATA[<p>本日よりブログを開始致しました。</p>
<p>弊社に関するニュースや、開発に関するトピックなどの記事を、発信していきます。</p>
<p>これからもどうぞよろしくお願い致します。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anycreative.net/2010/02/firstentry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

