<?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>Sara Trice</title>
	<atom:link href="http://saratrice.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://saratrice.com</link>
	<description>Just a programmin&#039;, bellydancin&#039;, cake bakin&#039; kinda girl</description>
	<lastBuildDate>Wed, 02 May 2012 15:29:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Indexing users that belong to groups with ancestry and thinking sphinx</title>
		<link>http://saratrice.com/2012/03/21/indexing-users-that-belong-to-groups-with-ancestry-and-thinking-sphinx/</link>
		<comments>http://saratrice.com/2012/03/21/indexing-users-that-belong-to-groups-with-ancestry-and-thinking-sphinx/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 20:03:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=278</guid>
		<description><![CDATA[So you&#8217;ve created a table of groups that are in a hierarchy with the gem ancestry, and you&#8217;ve created a table of users, and you&#8217;ve joined users to groups with a join table. And now you want to use Thinking Sphinx, which is awesome for searching. So you think, hey, wouldn&#8217;t it be great if [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve created a table of groups that are in a hierarchy with the gem <a href="https://github.com/stefankroes/ancestry" target="_blank">ancestry</a>, and you&#8217;ve created a table of users, and you&#8217;ve joined users to groups with a join table.</p>
<p>And now you want to use <a href="http://freelancing-god.github.com/ts/en/" target="_blank">Thinking Sphinx</a>, which is awesome for searching. So you think, hey, wouldn&#8217;t it be great if I could do a search for all users in a group&#8217;s subtree? Except that Thinking Sphinx cares not for your puny ancestry methods, and :subtree_ids doesn&#8217;t work in an index.</p>
<p>Fear not! I&#8217;ve done the heavy lifting for you.</p>
<blockquote>
<pre>
in user.rb:
define_index do
  indexes last_name
  has groups(:id), :as =&gt; :direct_group_ids
  has "CONCAT_WS('/',groups.id,groups.ancestry)", :as =&gt; :group_ids, :type =&gt; :multi
end</pre>
</blockquote>
<p>The first attribute is so that the join is made from users to groups. The second actually creates the multi-value attribute that you can search on. So from there you can do:</p>
<blockquote><p>User.search(:with_all => {:group_ids => [1]})</p></blockquote>
<p>That will give you all the users that belong to the subtree, including the root group (in this case, the group with the id of &#8220;1&#8243;).</p>
<p>That being said, if you only want the users from sub-groups of the group you&#8217;re searching on (i.e. you never want users that are directly attached to the group you&#8217;re searching on), you can instead do this:</p>
<blockquote>
<pre>
in user.rb:
define_index do
  indexes last_name
  has groups(:ancestry), :as =&gt; :group_ids, :type =&gt; :multi
end</pre>
</blockquote>
<p>So if you have group 1 which has group 2 and group 3 as children, the first example will give you all the users attached to all 3 groups; the second example will only give you the users attached to groups 2 and 3.</p>
<p>One last gotcha: if you&#8217;re running the search in console, remember to add &#8220;:per_page => 100&#8243; or however many entries you want back, or else by default you only get 20. Don&#8217;t want you to headdesk when you can&#8217;t figure out why it&#8217;s returning 20 users when it&#8217;s supposed to be returning 75.</p>
<p>Happy indexing!</p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2012/03/21/indexing-users-that-belong-to-groups-with-ancestry-and-thinking-sphinx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding Ruby hash conditionals in Ruby on Rails</title>
		<link>http://saratrice.com/2012/02/09/avoiding-ruby-hash-conditionals-in-ruby-on-rails/</link>
		<comments>http://saratrice.com/2012/02/09/avoiding-ruby-hash-conditionals-in-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 21:56:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=269</guid>
		<description><![CDATA[This gets really old: if params[:teacher] &#38;&#38; params[:teacher][:id] ... so instead, do this: if params[:teacher].try(:[], :id) or do it a lot more: name = params[:company][:owner][:name] if params[:company] and params[:company][:owner] and params[:company][:owner][:name] turns into: name = params.try(:[], :company).try(:[], :owner).try(:[], :name) Yay for Stack Overflow!]]></description>
			<content:encoded><![CDATA[<p>This gets really old:</p>
<blockquote>
<pre>if params[:teacher] &amp;&amp; params[:teacher][:id] ...</pre>
</blockquote>
<p>so instead, do this:</p>
<blockquote>
<pre>if params[:teacher].try(:[], :id)</pre>
</blockquote>
<p>or do it a lot more:</p>
<blockquote>
<pre>name = params[:company][:owner][:name] if params[:company] and params[:company][:owner] and params[:company][:owner][:name]</pre>
</blockquote>
<p>turns into:</p>
<blockquote>
<pre>name = params.try(:[], :company).try(:[], :owner).try(:[], :name)</pre>
</blockquote>
<p><a href="http://stackoverflow.com/questions/4371716/looking-for-a-good-way-to-avoid-hash-conditionals-in-ruby" target="_blank">Yay for Stack Overflow!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2012/02/09/avoiding-ruby-hash-conditionals-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quickie: How to add a blank option to options_from_collection_for_select</title>
		<link>http://saratrice.com/2011/12/28/quickie-how-to-add-a-blank-option-to-options_from_collection_for_select/</link>
		<comments>http://saratrice.com/2011/12/28/quickie-how-to-add-a-blank-option-to-options_from_collection_for_select/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 20:52:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=259</guid>
		<description><![CDATA[&#60;%= select_tag "some_select", ("&#60;option&#62;&#60;/option&#62;" + options_from_collection_for_select(@foo, "id", "item")).html_safe %&#62;]]></description>
			<content:encoded><![CDATA[<pre>&lt;%= select_tag "some_select", ("&lt;option&gt;&lt;/option&gt;" + options_from_collection_for_select(@foo, "id", "item")).html_safe %&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/12/28/quickie-how-to-add-a-blank-option-to-options_from_collection_for_select/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using javan/whenever on Engine Yard Cloud</title>
		<link>http://saratrice.com/2011/09/28/using-javanwhenever-on-engine-yard/</link>
		<comments>http://saratrice.com/2011/09/28/using-javanwhenever-on-engine-yard/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 19:31:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=252</guid>
		<description><![CDATA[UPDATE 4.17.2012: If you&#8217;re on EY and not using custom chef recipes, you should start. A whenever recipe has been written and is detailed here. Info on how to start using custom chef recipes is here. It&#8217;s not so bad, really. One gotcha: your &#8220;appname&#8221; in the recipe is not your rails application name, but [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE 4.17.2012: If you&#8217;re on EY and not using custom chef recipes, you should start. A whenever recipe has been written and is detailed <a href="http://blog.ethanvizitei.com/2010/10/whenever-gem-and-engineyard-appcloud.html">here</a>. Info on how to start using custom chef recipes is <a href="https://support.cloud.engineyard.com/entries/21009867-customize-your-environment-with-chef-recipes">here</a>. It&#8217;s not so bad, really. One gotcha: your &#8220;appname&#8221; in the recipe is not your rails application name, but your EY application name &#8211; these can be different things!</p>
<hr />
<p>Things I wish I&#8217;d have known:<br />
1. It does not matter if whenever is in your gemfile, you have to SSH to your EY server and install whenever as such: sudo gem install whenever<br />
2. It will probably complain that you don&#8217;t have i18n installed, so: sudo gem install i18n</p>
<p>EDIT: You will have to repeat the two steps above ANYTIME you restart your EY instance!</p>
<p>3. If you want your crontab updated on deploy, make a file named deploy/before_restart.rb and stick this in it (make sure you replace &#8216;yourAppNameHere&#8217;, derp):</p>
<pre>@rails_env = node[:environment][:framework_env]
run "cd #{release_path}; whenever --set environment=#{@rails_env}; whenever --update-crontab 'yourAppNameHere'"</pre>
<p>This is called a &#8216;deploy hook&#8217; and <a href="http://docs.engineyard.com/use-deploy-hooks-with-engine-yard-appcloud.html" target="_blank">here&#8217;s more info</a>.</p>
<p>I found the idea for this in <a href="http://webcache.googleusercontent.com/search?q=cache:ppp5Xh-9FocJ:community.engineyard.com/discussions/questions/786-gems-not-installing+%22%40rails_env+%3D+node%5B:environment%5D%5B:framework_env%5D%22&amp;cd=10&amp;hl=en&amp;ct=clnk&amp;gl=us" target="_blank">an old EY forum post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/09/28/using-javanwhenever-on-engine-yard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Illinois Home Bakeries &#8211; for farmer&#8217;s markets only</title>
		<link>http://saratrice.com/2011/09/09/illinois-home-bakeries-for-farmers-markets-only/</link>
		<comments>http://saratrice.com/2011/09/09/illinois-home-bakeries-for-farmers-markets-only/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 03:24:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[cakes]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=250</guid>
		<description><![CDATA[Interesting tidbit about a new law that is being passed. IL Senate Bill 840 allows for &#8220;Cottage food operations&#8221; (i.e. you can use your home kitchen), with several stipulations, if and only if you are selling goods at a farmers&#8217; market. So if I wanted to sell my cakes at a farmer&#8217;s market and got [...]]]></description>
			<content:encoded><![CDATA[<p>Interesting tidbit about a new law that is being passed. IL Senate Bill 840 allows for &#8220;Cottage food operations&#8221; (i.e. you can use your home kitchen), with several stipulations, if and <strong>only </strong>if you are selling goods at a farmers&#8217; market. So if I wanted to sell my cakes at a farmer&#8217;s market and got the appropriate paperwork, I could, but I still couldn&#8217;t sell them to individuals specifically out of my home. I&#8217;d <strong>have </strong>to have a table at a farmer&#8217;s market. Which is pretty much useless to me. Oh well, it&#8217;s a step in the right direction.</p>
<p><a href="http://www.news-gazette.com/news/politics-and-government/2011-08-25/new-law-settles-dispute-public-health-officials.html" target="_blank">Article from the News-Gazette<br />
</a><a href="http://www.ilstewards.org/blog/8509" target="_blank">Article from the IL Stewardship Alliance<br />
</a><a href="http://ilga.gov/legislation/billstatus.asp?DocNum=840&amp;GAID=11&amp;GA=97&amp;DocTypeID=SB&amp;LegID=55671&amp;SessionID=84" target="_blank">Senate bill 840 </a></p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/09/09/illinois-home-bakeries-for-farmers-markets-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jsTree: adding Expand All and Collapse All buttons</title>
		<link>http://saratrice.com/2011/05/04/jstree-adding-expand-all-and-collapse-all-buttons/</link>
		<comments>http://saratrice.com/2011/05/04/jstree-adding-expand-all-and-collapse-all-buttons/#comments</comments>
		<pubDate>Wed, 04 May 2011 19:50:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=240</guid>
		<description><![CDATA[The documentation for jsTree is thorough, but not particularly easy to read. If you are looking for an easy way to add &#8220;Expand All&#8221; and &#8220;Collapse All&#8221; buttons, here&#8217;s one way: &#60;input type="button" value="Collapse All" onclick="$('#tree_container_id').jstree('close_all');"&#62; &#60;input type="button" value="Expand All" onclick="$('#tree_container_id').jstree('open_all');"&#62; where &#8216;#tree_container_id&#8217; is, of course, the ID of the container node for your tree.]]></description>
			<content:encoded><![CDATA[<p>The documentation for jsTree is thorough, but not particularly easy to read. If you are looking for an easy way to add &#8220;Expand All&#8221; and &#8220;Collapse All&#8221; buttons, here&#8217;s one way:</p>
<p><code>&lt;input type="button" value="Collapse All" onclick="$('#tree_container_id').jstree('close_all');"&gt;<br />
&lt;input type="button" value="Expand All" onclick="$('#tree_container_id').jstree('open_all');"&gt;<br />
</code></p>
<p>where &#8216;#tree_container_id&#8217; is, of course, the ID of the container node for your tree.</p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/05/04/jstree-adding-expand-all-and-collapse-all-buttons/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Uploadify: changing scriptData with dropdowns</title>
		<link>http://saratrice.com/2011/04/11/uploadify-changing-scriptdata-with-dropdowns/</link>
		<comments>http://saratrice.com/2011/04/11/uploadify-changing-scriptdata-with-dropdowns/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 20:26:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=227</guid>
		<description><![CDATA[Uploadify is a pretty awesome jQuery/flash uploader. It&#8217;s made even more awesome by the stuff you can do with it on the fly. For example, if you want to pass a variable chosen from a dropdown via the uploader, you can use uploadifySettings() to do so. Some people appear to have problems with this part, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.uploadify.com" target="_blank">Uploadify</a> is a pretty awesome jQuery/flash uploader. It&#8217;s made even more awesome by the stuff you can do with it on the fly.</p>
<p>For example, if you want to pass a variable chosen from a dropdown via the uploader, you can use <a href="http://www.uploadify.com/documentation/methods/uploadifysettings/" target="_blank">uploadifySettings()</a> to do so. Some people appear to have problems with this part, so here&#8217;s how I did it. (I&#8217;m not going to show you all the settings, since the <a href="http://www.uploadify.com/documentation/">docs</a> give you a pretty good idea how to set it up. )</p>
<p>Say you have a dropdown in your form with the id of &#8216;upload_type&#8217;:<br />
<code><br />
&lt;select id="upload_type" name="upload_type"&gt;<br />
&lt;option&gt;&lt;/option&gt;<br />
&lt;option value="1"&gt;First type&lt;/option&gt;<br />
&lt;option value="2"&gt;Second type&lt;/option&gt;<br />
&lt;/select&gt;<br />
</code></p>
<p>In your jQuery $(document).ready function (but outside the $(&#8216;#upload&#8217;).uploadify function), put something like this:<br />
<code><br />
$('#upload_type').change(function() {<br />
var type_val = $(this).val();<br />
$('#upload').uploadifySettings("scriptData", {"upload_type" : type_val});<br />
});<br />
</code><br />
Which means &#8220;Whenever the form field identified with &#8216;upload_type&#8217; changes, update the &#8216;upload_type&#8217; variable in scriptData if it exists; if it does not already exist in scriptData, add it.&#8221;</p>
<p>Note: I&#8217;ve only tried this in Uploadify 2.1.4.</p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/04/11/uploadify-changing-scriptdata-with-dropdowns/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Music industry shifts to being a service? Good news, bad news&#8230;</title>
		<link>http://saratrice.com/2011/03/23/music-industry-shifts-to-being-a-service-good-news-bad-news/</link>
		<comments>http://saratrice.com/2011/03/23/music-industry-shifts-to-being-a-service-good-news-bad-news/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 18:01:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ramblings]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=223</guid>
		<description><![CDATA[Here&#8217;s an interesting read from Ars Technica: Did file-sharing cause recording industry collapse? Economists say no The most interesting paragraph I see in this article is this one: So what is emerging is an increasingly &#8220;ephemeral&#8221; global music culture based not upon the purchasing of discrete physical packages of music, but on the discovery and [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting read from Ars Technica:</p>
<p><a href="http://arstechnica.com/tech-policy/news/2011/03/is-file-sharing-the-global-future.ars" target="_blank">Did file-sharing cause recording industry collapse? Economists say no</a></p>
<p>The most interesting paragraph I see in this article is this one:</p>
<blockquote><p>So what is emerging is an increasingly &#8220;ephemeral&#8221; global music culture based not upon the purchasing of discrete physical packages of music, but on the discovery and subsequent promotion of musicians through file sharing. The big winner in this model is not the digital music file seller, but the touring band, whose music is easily discoverable on the &#8216;Net. As with so much of the rest of the emerging world economy, the shift is away from buying things and towards purchasing services—in this case tickets to concerts and related activities.</p></blockquote>
<p>So I have to wonder &#8211; to my friends (and my husband) who count on selling merch at their unpaid performances &#8211; is this a game changer? Will musicians from now on be ultimately unable to make a living unless they go on the road &#8211; and stay there?</p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/03/23/music-industry-shifts-to-being-a-service-good-news-bad-news/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing CKEditor in Ruby on Rails with Cucumber/Capybara</title>
		<link>http://saratrice.com/2011/03/09/testing-ckeditor-in-ruby-on-rails-with-cucumbercapybara/</link>
		<comments>http://saratrice.com/2011/03/09/testing-ckeditor-in-ruby-on-rails-with-cucumbercapybara/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 00:25:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=215</guid>
		<description><![CDATA[I have a textarea with the id of &#8220;request_details&#8221;, made into a CKEditor instance by jQuery: $(&#8216;#request_details&#8217;).ckeditor(); (Check this page if you need some help getting CKEditor to work with jQuery, it&#8217;s dead simple) Feature looks like this:  And I fill in "Here are some details" in the CKEditor instance "request_details" Step looks like this: [...]]]></description>
			<content:encoded><![CDATA[<p>I have a textarea with the id of &#8220;request_details&#8221;, made into a CKEditor instance by jQuery: $(&#8216;#request_details&#8217;).ckeditor();</p>
<p>(Check <a href="http://ckeditor.com/blog/CKEditor_for_jQuery" target="_blank">this page</a> if you need some help getting CKEditor to work with jQuery, it&#8217;s dead simple)</p>
<p>Feature looks like this:  <code>And I fill in "Here are some details" in the CKEditor instance "request_details"</code></p>
<p>Step looks like this:</p>
<p style="padding-left: 30px;"><code>When /^I fill in "([^"]*)" in the CKEditor instance "([^"]*)"$/ do |value, input_id|<br />
browser = page.driver.browser<br />
browser.execute_script("CKEDITOR.instances['#{input_id}'].setData('#{value}');")<br />
end</code></p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/03/09/testing-ckeditor-in-ruby-on-rails-with-cucumbercapybara/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>My least favorite phrase</title>
		<link>http://saratrice.com/2011/02/23/my-least-favorite-phrase/</link>
		<comments>http://saratrice.com/2011/02/23/my-least-favorite-phrase/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 21:52:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ramblings]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://saratrice.com/?p=213</guid>
		<description><![CDATA[I&#8217;ve decided on my least favorite phrase in the English language: &#8220;Can&#8217;t you just&#8230;?&#8221; Why is this my least favorite phrase? Because: It&#8217;s always in conjunction with a task that the questioner does not understand, but assumes should not be difficult at all; it is inherently second-guessing the person being asked, which is insulting; and, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided on my least favorite phrase in the English language:</p>
<p><strong>&#8220;Can&#8217;t you just&#8230;?&#8221;</strong></p>
<p>Why is this my least favorite phrase? Because:</p>
<ol>
<li>It&#8217;s always in conjunction with a task that the questioner does not understand, but assumes should not be difficult at all;</li>
<li>it is inherently second-guessing the person being asked, which is insulting;</li>
<li>and, rather than asking if something is possible, as in &#8220;Can you?&#8221; or &#8220;Could you?&#8221;, the speaker is really saying, &#8220;This must be possible, and if you can&#8217;t do it, you&#8217;re an idiot.&#8221;</li>
</ol>
<p>If you don&#8217;t understand how the system works, or what is involved with doing a task, please, ask if something is possible. Don&#8217;t demean the craftsman or browbeat them into doing whatever it is you want. A resentful craftsman is not on your side, and will not go out of his/her way to help you.</p>
]]></content:encoded>
			<wfw:commentRss>http://saratrice.com/2011/02/23/my-least-favorite-phrase/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

