tag:blogger.com,1999:blog-276667772008-06-11T08:29:24.916-05:00thoughts by CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comBlogger51125tag:blogger.com,1999:blog-27666777.post-15027209418227925332008-05-20T21:38:00.002-05:002008-05-22T10:25:12.311-05:00New JobSo I just started my new job and moved in to an apartment for the summer before I head back to school in the fall. I figured I would post a few pictures of my new place for all those internet stalkers out there. :) Since I'll primarily be doing rails development with a little .net tossed in there look for some tidbits of knowledge I pick up along the way.<div><br /></div><div>-CH<br /><br />http://www.flickr.com/photos/johnsonch/sets/72157605170352155/<br /></div>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-39512071446546777962008-04-30T20:20:00.001-05:002008-04-30T20:20:55.245-05:00Code Camp 5So Code Camp 5 has been announced (http://www.twincitiescodecamp.com) and once again I'll be speaking on something other than .NET to give developers some exposure to other tools that they can use to expand their knowledge. This session I am co-presenting with Brian Hogan of NAPCS (http://www.napcs.com), 'Becoming a Documentation Ninja'. The focus of our topic is using DocBook to create and manage your documentation. I have found DocBook quite interesting and it makes maintaining documentation less frustrating then using Word. As I dive more into DocBook I will keep posting my finds. Brian on the other hand has been using DocBook for awhile now working on his two books (I'm hoping are released soon).johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-67589280223212928212008-04-08T08:53:00.002-05:002008-04-08T09:03:38.879-05:00Back on the blog.....Ok so I have really been slacking lately, but hey with school and work things are really crazy. Its been a crazy week, I was able to present at <a href="http://twincitiescodecamp.com/">Code Camp</a> last Saturday. It was a great experience to present to such a large group. While at Code Camp I was able to talk to and meet many great people,<a href="http://geekswithblogs.net/dlussier/Default.aspx">D’Arcy Lussier</a>, <a href="http://subjunctive.wordpress.com/">Chris Sutton</a>, and <a href="http://blog.lozanotek.com/">Javier Lozano</a> among others. It was amazing the discussions that we had there. My talk went off good and had some great people in the session that contributed to the discussion even teaching me a thing or two.<br /><br />Later in the day I went to a couple different sessions about MVC and .NET. The first one was put on by <a href="http://subjunctive.wordpress.com/">Chris Sutton</a>, it was a second part to the introduction of Microsoft's MVC Framework for ASP.NET it was very interesting and brought me closer to understanding .NET by actually being able to implement a web application in the style I like to use.<br /><br />The second session I went to was put on by <a href="http://geekswithblogs.net/dlussier/Default.aspx">D’Arcy Lussier</a>, this was a very informational session as D'Arcy skipped the powerpoint and code examples and led us in a round table discussion of .NET, MVC, and general web application theories. It was nice to hear that I'm not the only one that feels that the ASP.NET framework has brought about a mass amount of developers that don't understand statelessness.<br /><br /><a href="http://www.johnsonch.com/resources/Code_Camp_Spring_2008.zip">Here is my code and slide deck from Code Camp</a>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-51136584937160480932008-02-07T09:04:00.001-06:002008-02-07T09:04:34.480-06:00Installing ImageMagick and RMagick on OS XI ran into a little problem the other day.  I needed to use ImageMagick and RMagick to do some image handling in a system I am working on.  So I busted out the "Rails Cookbook" from O'Reilly, and followed along with the directions of setting up my development machine.  Part way through their tutorial nothing was working at all so I decided to look for some other directions on getting everything set up.  I found some information leading me to believe that Mac Ports would be the best way to install both ImageMagick and RMagick.  This turns out to be only half true, while ImageMagick works great from the Mac Ports install RMagick does not.  The solution I found was to use gems to install RMagick.  Word of caution once you install RMagick with Mac Ports it blows away all your gems.  I have had to reinstall all of my gems including Rails 1.2.3.  Take my advice with a grain of salt but this is what I had found out.<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-91934927629804688102007-12-04T14:15:00.001-06:002007-12-04T14:15:20.521-06:00Its Beging To Look A Lot Like ChristmasSo in my new diggs at least I can look out side and its snowing!  I like snow cause then I can play with my snowblower.  I know this sounds like a dorky thing but I actually like snowblowing and even mowing the lawn from time to time.  But at least with snowblowing I can make a big mound of snow!johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-78701674998412203272007-11-26T15:22:00.000-06:002007-11-26T15:24:21.621-06:00Office RemodelSo here I sit in a random cube across the office from where I usually work. The cube is a little different than what I am used to. My really old office used to be in a computer lab and when I transfered from UW-Stout to UW-Eau Claire we were working a room in the basement of one of the buildings. Then we got moved to a large cube were all of the students work in another building. In our new diggs they decided to build a wall now so we are scattered throughout the entire office area in random cubes. It's not bad working on my laptop because I am mobile, everyone else is crammed into one regular cube which is way to hot for me.<br /><br /><br /><br />I have been working on a housing listing site and just started to implement the advanced search feature. I found that I had not handled all the edge cases in my tests. Have no fear its up and working and of course I have some code to show you.<br /><br /><br /><br /><br />Here it is:<br /><pre><br />def self.search(params = {})<br /><br /> composed_cond = EZ::Where::Condition.new<br /> <br /> cond_number_of_bedrooms = EZ::Where::Condition.new :properties do <br /> number_of_bedrooms == params[:search][:number_of_bedrooms]<br /> end<br /> <br /> cond_min_price = EZ::Where::Condition.new :properties do <br /> if !params[:search][:min_price].blank?<br /> price >= params[:search][:min_price]<br /> end <br /> end<br /> <br /> <br /> cond_max_price = EZ::Where::Condition.new :properties do <br /> if !params[:search][:max_price].blank?<br /> price <= params[:search][:max_price]<br /> end <br /> end<br /> <br /> composed_cond << cond_number_of_bedrooms<br /> composed_cond << cond_min_price<br /> composed_cond << cond_max_price<br /> <br /><br /> @properties = Property.find(:all, <br /> :include =>[:amenities, :utilities],<br /> :conditions => composed_cond.to_sql) <br />end<br /></pre><br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-26464647756038848052007-11-15T15:12:00.001-06:002007-11-15T15:12:19.793-06:00Elf List Goes LiveI really don't have much to say, but Elf List is live and ready for use.  Its in the pre-beta release with features to arive daily.  So check it out, http://www.elflist.net<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-39165619651360723692007-11-12T23:22:00.000-06:002007-11-12T23:25:11.993-06:00Godfather on WiiSo time for another one of my reviews. Last week I finally picked up a copy of Godfather for the Wii on the recommendation of a friend. I really can't say more than this game rocks. I have had a great time playing it even though it has sucked me in for many hours already (as if I didn't have a million other things to do). So if your going to get it make sure you have a few hours of free time on your hands as the missions are completable but not overly hard making the game play very enjoyable from the start. Speaking of Godfather I better get back to my game.<br /><br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-56838806574450584082007-10-27T16:11:00.000-05:002007-10-27T16:23:17.843-05:00find or create bySo today I was working on a venture application I am trying to develop, when I cam across the need to only create a product if its not in the database. In this case I want to create the product only if the name of it is not in the database. While this is dangerous because of spelling but I am trying to keep it open for local (community) use. Slang terms may come up for one area so they need to be allowed. However I was having a difficult time looking at the pile of code for actually doing this.<br /><br /><pre> if Product.find_by_name("spotted cow")<br /> product = Product.find_by_name("spotted cow")<br />else<br /> product = Product.create(:name => "spotted cow")<br />end</pre><br /><br />So I found out about this method from someone in the rails chat on irc.freenode.net (there is always someone willing to help in that chat room.)<br /><br /><pre>Product.find_or_create_by_name( params[:product][:name],<br /> :category_id => params[:product][:category_id],<br /> :for => 'creation' )</pre><br />So now the product will be either found or created by the name of the product and if it is going to be created it adds the category_id just like a normal create.<br /><br />Here is the test that proves this works.<br /><pre><span style="font-family:monospace;"> def test_find_or_create_by_name<br /> assert Product.find_or_create_by_name("spotted cow",<br /> :category_id => 1,<br /> :for => :create)<br /> </span><span style="font-family:monospace;">assert Product.find_or_create_by_name("spotted cow",<br /> :category_id => 1,<br /> :for => :create)</span><br /><span style="font-family:monospace;"> </span><span style="font-family:monospace;">assert Product.find_or_create_by_name("spotted cow",<br /> :category_id => 1,<br /> :for => :create)</span><br /><span style="font-family:monospace;"> assert Product.find_or_create_by_name("spotted cow",<br /> :category_id => 1,<br /> :for => :create)</span><br /><span style="font-family:monospace;"> <br /> products = Product.find_all_by_name("spotted cow")<br /> assert_equal(1, products.length)<br />end<br /></span> </pre><br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-87648106133293107312007-10-26T08:24:00.000-05:002007-10-26T08:31:06.761-05:00CVNUG (Chippewa Valley .Net User Group)Last night I was able to explain the basics of Ruby on Rails to the .Net group that I belong to. It was really a great experience and was greatly received by the group. I was nervous about the response I would get initially from the group as some members of the Rails community come across as arrogant bastards.<br /><br /> The presentation when off with out a hitch thanks to the help of Brian Hogan (<a href="http://www.napcs.com/">http://www.napcs.com/</a>) who was there to answer questions and explain information more in depth as I demonstrated building a "Cookbook" application. I stripped down a version of Brian's cookbook tutorial and turned it in to a demonstration.<br /><br /> I want to give a shout out to CVNUG (http://cvnug.wi-ineta.org/) for letting me present to them the wonders of working with Rails. I would also like to thank Brian for helping me out with the presentation.<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-23387025933730091912007-10-23T13:30:00.001-05:002007-10-23T13:30:10.963-05:00Connecting to ms SQL from OS XThis one got me again today as I usually do not use SQL Server for my rails apps.  I was having a hard time remembering the steps for updating my odbc connector for SQL server.  Brian Hogan over at New Auburn Personal Computer Services has a great post on how to do this so check it out here: <br />http://www.napcsweb.com/blog/2007/03/08/15/#more-15johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-46963880322496832007-10-11T15:40:00.001-05:002007-10-11T15:40:47.686-05:00Rock N' Roll JesusI recently purchased Kid Rock's new album, "Rock N' Roll Jesus"  So far I have really enjoyed this album.  All I can really say is this is a great album and Kid Rock is keeping up his tradition of keeping the southern-rock-rap-country mix flowing.  Like every other Kid Rock album it's going to be a main stay in my car and on my ipod!johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-10712169010142364742007-10-02T13:38:00.001-05:002007-10-02T13:38:50.425-05:00Installing CS3 in OS XToday I was upgrading my Adobe products to CS3 from CS2 and ran into a problem.  There was an issue with my "payload" so the installer could not function properly.  After an hour of searching I found the CS3 Clean application from adobe.  It clears out all of your previous adobe information and allows the install of CS3 to work like a charm.  I figured someone else maybe having this same problem so here is the direct link.<br />http://www.adobe.com/support/contact/cs3clean.html<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-906412815339923782007-09-10T23:34:00.000-05:002007-09-10T23:44:37.089-05:00Ok Seriously I need to keep bloggingWell Rails Rumble is over, and we have our site up. <a href="Http://www.elflist.us">http://www.elflist.us</a> If you want to check it out. The weekend was great, we had a super team just ran out of time. If there is something that I learned from this contest it is that if you put your mind to something you can get it done. We plan on working on Elf List in the next couple months and I hope we can take the beta version live to the public for use around the beginning of November. For information on the development of Elf List check out <a href="http://www.icanhaztrofy.com">http://www.icanhaztrofy.com </a>where you will find our team blog.<br /><br />In other news I am almost finished with <a href="http://www.LauraSaidYes.net">LauraSaidYes.net</a> sometime next week I should have the site live. Its been such a crazy last couple of weeks with the start of school and the Rumble but now that everything has calmed down back to my crazy life I can concentrate on a million things rather than a million and one. :)<br /><br />One more news worthy note, in October I will be presenting Ruby on Rails to the Chippewa Valley .Net User Group (<a href="http://cvnug.wi-ineta.org">http://cvnug.wi-ineta.org</a>). This should be an exciting presentation opening some .Net developers to my world as they open me up to theirs every month.<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-79029794069366098732007-08-31T07:57:00.001-05:002007-08-31T08:03:52.292-05:00Busy BusyThe last few weeks I haven't been able to post because I have been super busy. Coming up next weekend is the Rails Rumble (http://www.railsrumble.com) I have joined up with 2 other developers and a really good graphic designer. You can find out more about our project at http://www.icanhaztrofy.com we have a simple blog up that will be used during the 48 hour contest.<br /><br />In other news I recently got engaged this past weekend. It really has been a blessing to have Laura in my life and her continuing support for me and everything I do. <br /><br />Lastly I am presenting RoR to a group of .Net developers that I meet with every month. I will try and get my slidedeck up here as soon as I finish it for others to take a look at. Since I have been trying to learn .Net I think this will be a good communication point for me. I will say this, after programing in Ruby it makes it harder to want to give it up for another language. Because everything just makes sense. <br /><br />Well stay tunned for more to come, as the fall semester is about to start I will inevitably find more information to share with the world.<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-85918332063691995292007-08-13T10:59:00.000-05:002007-08-13T11:14:14.064-05:00Back to Search Results<p>So today I encountered a problem that I seem to encounter in every web application I develop. Most web applications require a search and a way to view each results details. When you view the details you most of the time want to go back to your search results and not have to re-enter all of the fields of your search form.</p><br /><br /><p> There are a few ways to do this.<br /><br />First you can use the quick and dirty way that will not work all the time.</p><br /><pre><br /> input value="Go" onclick="history.go(-1)" type="button"<br /></pre><br /><p>The javascript function history.go is very useful if the client has javascript enabled. If they do not have javascript enabled this button will do absolutely nothing and frustrate your user beyond all means</p><br /><p>The second option is to use the server to store the search params</p><br /><pre><br /># staff_controller.rb<br /> def view_applications<br /> if params[:type] == "requery"<br /> search_params = session[:search_params]<br /> else<br /> search_params = params<br /> session[:search_params] = params<br /> end<br /> @applications = Staff.find_applications_by_params(search_params)<br /> end<br /></pre><br /><p>As you can see when the view_applications method is called the params are checked for a variable called type, if this is being called from the original search that field would be empty and the else portion kicks in causing the params to be stored in session. Below you will see the link_to example from the page that shows the details of a record. You will notice that the params have a type that is set to requery, which triggers the function to use the params from session to display the results.</p><br /><pre><br /> link_to "<< Back to Search Results", :action => :view_applications, :type => "requery"<br /></pre><br /><p>There you have it, a way in rails to use the search results from before. If you have any other ways of doing this please post a comment.<br /><br /><br />Enjoy,<br />-CH</p>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-53542355631918929882007-08-08T14:39:00.000-05:002007-08-08T14:40:19.950-05:00"Chocolate Rain" space150 intern REMIX<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/scML5KFx5SU"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/scML5KFx5SU" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-55396063868707836212007-08-06T15:15:00.001-05:002007-08-06T15:15:49.698-05:00Guitar Hero III<p>So I found this post on digg........</p><br /><br /><br /><object height="350" width="425"><param name="movie" value="http://www.youtube.com/v/_ZutgOyA9EY"><param name="wmode" value="transparent"><embed src="http://www.youtube.com/v/_ZutgOyA9EY" type="application/x-shockwave-flash" wmode="transparent" height="350" width="425"></embed></object>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-43555829920311393462007-08-01T14:55:00.000-05:002007-08-01T14:59:26.996-05:00RoR GotchasSo today I was working on re-factoring an application that I was handed. The application had everything plugged in the controller initially so in the name of MVC I started to move things to the model file. While in the model I had a method that looked like this:<br /><br /><pre><br /> def self.find_applications(params)<br /> composed_cond = Caboose::EZ::Condition.new<br /> <br /> cond_three_letter_code = Caboose::EZ::Condition.new :programs do <br /> three_letter_code === params[:find_only_program_codes]<br /> end<br /> <br /> cond_status = Caboose::EZ::Condition.new :study_abroad_applications do<br /> status === params[:find_only_statuses].<br /> to_s.downcase.gsub(" ", "").gsub(",", ";").split(";")<br /> end<br /> <br /> cond_terms = Caboose::EZ::Condition.new :deadlines do<br /> term_year === params[:find_only_terms].<br /> to_s.downcase.gsub(" ", "").gsub(",", ";").split(";") <br /> end<br /> <br /> composed_cond << cond_three_letter_code<br /> composed_cond << cond_terms<br /> composed_cond << cond_status<br /><br /> @applications = StudyAbroadApplication.find(:all, <br /> :include=>[{:deadline => :program}, :user],<br /> :conditions => composed_cond.to_sql, :order => "deadlines.id")<br /> <br /> unless @applications == 0<br /> puts "Size: #{@applications.size}"<br /> else<br /> flash[:notice] = "There was an error retrieving your application records"<br /> redirect_to :action => "index"<br /> end<br />end<br /></pre><br /><br />With me being a noob to RoR I completely forgot about my background in procedure based programing and thought nothing of the last statement. Hell if it puts out the size of the array thats what I wanted right? Well that was what I got, but what I didn't get was the @applications array that I wanted to display in my view. So there you have it just make sure that the last thing in your method is what you want to return. Learn from my mistakes and save your self some tail chasing. :)<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-62475280708604755782007-07-27T08:53:00.001-05:002007-07-27T08:53:58.988-05:00Funny FridayI got this in an email and it was actually funny!<br /><br />-CH<br /><br /><blockquote>The following is an actual question given on a University of Washington<br />chemistry mid-term.<br /><br />The answer by one student was so "profound" that the professor shared it<br />with colleagues, via the Internet, which is, of course, why we now have<br />the pleasure of enjoying it as well.<br /><br />Bonus Question: Is Hell exothermic (gives off heat) or endothermic<br />(absorbs heat)?<br /><br />Most of the students wrote proofs of their beliefs using Boyle's Law<br />(gas cools when it expands and heats when it is compressed) or some variant.<br />One student, however, wrote the following:<br /><br />"First, we need to know how the mass of Hell is changing in time. So we<br />need to know the rate at which souls are moving into Hell and the rate<br />at which they are leaving. I think that we can safely assume that once a<br />soul gets to Hell, it will not leave. Therefore, no souls are leaving.<br /><br />As for how many souls are entering Hell, let's look at the different<br />religions that exist in the world today. Most of these religions state<br />that if you are not a member of their religion, you will go to Hell.<br />Since there is more than one of these religions and since people do not<br />belong to more than one religion, we can project that all souls go to<br />Hell. With birth and death rates as they are, we can expect the number<br />of souls in Hell to increase exponentially.<br /><br />Now, we look at the rate of change of the volume in Hell because Boyle's<br />Law states that in order for the temperature and pressure in Hell to stay<br />the same, the volume of Hell has to expand proportionately as souls are added.<br /><br />This gives two possibilities:<br /><br />1. If Hell is expanding at a slower rate than the rate at which souls<br />enter Hell, then the temperature and pressure in Hell will increase<br />until all Hell breaks loose.<br /><br />2. If Hell is expanding at a rate faster than the increase of souls in<br />Hell, then the temperature and pressure will drop until Hell freezes<br />over.<br /><br />So which is it? If we accept the postulate given to me by Teresa during<br />my Freshman year that, 'It will be a cold day in Hell before I sleep with<br />you,' and take into account the fact that I slept with her last night,<br />then number two must be true, and thus I am sure that Hell is exothermic<br />and has already frozen over.<br /><br />The corollary of this theory is that since Hell has frozen over, it<br />follows that it is not accepting any more souls and is therefore,<br />extinct...leaving only Heaven, thereby proving the existence of a divine<br />being which explains why, last night, Teresa kept shouting 'Oh my God.'"<br /><br />THIS STUDENT RECEIVED THE ONLY "A"</blockquote>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-39159723519139494132007-07-25T09:00:00.000-05:002007-07-25T14:46:45.517-05:00First 10 Minutes With IronRubySo yesterday after reading John Lam's blog (<a href="http://www.iunknown.com/2007/07/a-first-look-at.html">http://www.iunknown.com/2007/07/a-first-look-at.html</a>) post about IronRuby I thought I would give it a try. I downloaded the source and built the project using visual studio 2005. Next I opened up Scott Guthrie's blog (<a href="http://weblogs.asp.net/scottgu/archive/2007/07/23/first-look-at-ironruby.aspx">http://weblogs.asp.net/scottgu/archive/2007/07/23/first-look-at-ironruby.aspx</a>) and was looking at his example of using IronRuby with WPF. I soon had 'hello world' put out on the console and in a dialog box.<br /><br />After getting 'hello world' out there I wanted to start playing. First I wanted to display the current time out to the screen so I tried out the ruby command Time.now, no dice. I got a message saying "uninitialized constant Time", I thought Time.now was automatically initialized by system.<br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_n3PH8R3exHo/Rqddzfml1JI/AAAAAAAAAAo/NUineoFuP3M/s1600-h/Picture+7.png"><img style="margin: 0pt 10px 10px 0pt; cursor: pointer;" src="http://bp3.blogger.com/_n3PH8R3exHo/Rqddzfml1JI/AAAAAAAAAAo/NUineoFuP3M/s320/Picture+7.png" alt="" id="BLOGGER_PHOTO_ID_5091141043003708562" border="0" /></a><br /></div><br />The next thing I tried that didn't work was using instance variables. I tried to use the statement: @msg = 'Hello World' and soon my console was filled with error messages. I was however able to use this statement: msg = 'Hello World'. I don't know if they plan on letting you use instance variables in IronRuby or not.<br /><br />So over all I was not greatly impressed with IronRuby but am still excited for new versions to come. I guess 'Rome wasn't built in a day' and the progress the IronRuby team has made is in the right direction. Again I only played with this for 10 minuets thus am not an expert. So go out try it and let me know what you think.<br /><br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-59020338244377778942007-06-27T07:53:00.000-05:002007-07-25T09:42:04.699-05:00Using ez_whereWhile reading the documentation for the ez_where plugin in rails I got a little confused as I am a noob to rails. So once I figured out how to use this plugin I was able to develop tests and search functionality for an eight field search in under 5 hours. This was amazing to me coming from a classic asp background where this type of functionality would have taken a few days at least since some of the relationships would have required a very complex sql statement. But enough of my rambling lets get to the code.....<br /><br />First off you'll want to get the ez_where plugin (<a href="http://opensvn.csie.org/ezra/rails/plugins/dev/ez_where/">http://opensvn.csie.org/ezra/rails/plugins/dev/ez_where/</a>) inside the readme file the author provides several examples that are great and what I based my search off of. The nice part about this plugin is the way it extends active record. Rather then doing a Class.find(:all) you use Class.ez_find(:all) these will return the same results the fun part comes when you have two tables with related data that you want to search on. I'm going to use the authors examples and explain them a little more so thanks to Ezra Zygmuntowicz &amp; Fabien Franzen for this great plugin.<br /><br />First example:<br /><pre><br />articles = Article.ez_find(:all, :include => :author) do |article, author|<br /> article.title =~ "%Foo Title%"<br /> author.any do<br /> name == 'Ezra'<br /> name == 'Fab'<br /> end<br />end<br /></pre><br />So first off we have the variable that we want to store the results in, in this case were looking for articles so were going to search using the main class of Article by implementing the ez_find method we are looking for all articles and also including the author association. This is what got me confused, as I stated I come from a procedural programming background using classic asp and the way I would have done this in asp would have been to write a humongous sql statement to search across the tables. So when I was reading the example I mistook the include => author for include the author table not the association that article. This was the biggest thing that I struggled with. So drop your associations in place and then build your logic for the search. I'm going to include my search as another example of how to implement this plugin.<br /><br /><pre><br />def self.search(params)@alum = Alum.ez_find(:all,<br /> :include => [:majors, :minors, :industry, :job_function])<br /> do |alums, majors, minors, industry, job_function|<br /> unless params[:search][:major].nil?<br /> majors.id == params[:search][:major]<br /> end<br /><br /> unless params[:search][:minor].nil?<br /> minors.id == params[:search][:minor]<br /> end<br /><br /> unless params[:search][:industry].nil?<br /> industry.id == params[:search][:industry]<br /> end<br /><br /> unless params[:search][:job_function].nil?<br /> job_function.id == params[:search][:job_function]<br /> end<br /><br /> unless params[:search][:employer].nil?<br /> alums.employer == params[:search][:employer]<br /> end<br /><br /> unless params[:search][:city].nil?<br /> alums.city == params[:search][:city]<br /> end<br /><br /> unless params[:search][:state].nil?<br /> alums.state == params[:search][:state]<br /> end<br />end<br />end<br /></pre><br /><br />And now a test case example:<br /><pre><br />def test_search_for_employer_dimeo_family<br />alum = Alum.search(:search => {:employer => "DiMeo Family"})<br />assert_equal(3, alum.size)<br />assert alum.detect {|a| a.first_name == "Tony"}<br />assert alum.detect {|a| a.first_name == "Bobby"}<br />assert alum.detect {|a| a.first_name == "Christopher"}<br />end<br /></pre><br />And Finally the controller action:<br /><pre><br />def search_results<br /> @alums = Alum.search(params)<br /> render :action => "list"<br />end<br /></pre>There you have it, another example and my two cents.<br /><br />Enjoy!<br />-CHjohnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-29424898763524778412007-01-08T10:01:00.000-06:002007-01-08T10:01:17.371-06:00Night Time<a href="http://bp2.blogger.com/_n3PH8R3exHo/RaJqzQn9-sI/AAAAAAAAAAc/iNxzcix6hwo/s1600-h/IMG_8435.JPG"><img id="BLOGGER_PHOTO_ID_" style="CLEAR: both; FLOAT: left" alt="" src="http://bp2.blogger.com/_n3PH8R3exHo/RaJqzQn9-sI/AAAAAAAAAAc/iNxzcix6hwo/s320/IMG_8435.JPG" border="0" /></a> Night time on the Milwaukee River.<div style='clear:both; text-align:LEFT'><a href='http://picasa.google.com/blogger/' target='ext'><img src='http://photos1.blogger.com/pbp.gif' alt='Posted by Picasa' style='border: 0px none ; padding: 0px; background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;' align='middle' border='0' /></a></div>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-84302075257093871792006-12-31T15:22:00.000-06:002006-12-31T15:22:14.919-06:00Cedar Creek Park<a href="http://bp3.blogger.com/_n3PH8R3exHo/RZgqB-WSg7I/AAAAAAAAAAU/gGh742awDKA/s1600-h/IMG_8560.JPG"><img style="CLEAR: both; FLOAT: left" alt="" src="http://bp3.blogger.com/_n3PH8R3exHo/RZgqB-WSg7I/AAAAAAAAAAU/gGh742awDKA/s320/IMG_8560.JPG" border="0" /></a> Just playing around with long exposures and getting the blur in the running water.<div style='clear:both; text-align:LEFT'><a href='http://picasa.google.com/blogger/' target='ext'><img src='http://photos1.blogger.com/pbp.gif' alt='Posted by Picasa' style='border: 0px none ; padding: 0px; background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;' align='middle' border='0' /></a></div>johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.comtag:blogger.com,1999:blog-27666777.post-1163563424217350242006-11-14T22:03:00.000-06:002006-11-14T22:03:44.226-06:00Water<a href="http://photos1.blogger.com/blogger/4281/2918/640/IMG_6080.jpg"><img style="CLEAR: all; FLOAT: left; MARGIN: 0px 10px 10px 0px; CURSOR: hand" alt="" src="http://photos1.blogger.com/blogger/4281/2918/320/IMG_6080.jpg" border="0" /></a> Nothing to exciting just some water drops up really close.&nbsp;<a href='http://picasa.google.com/blogger/' target='ext'><img src='http://photos1.blogger.com/pbp.gif' alt='Posted by Picasa' style='border: 0px none ; padding: 0px; background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;' align='middle' border='0' /></a> johnsonchhttp://www.blogger.com/profile/11714791141533818696noreply@blogger.com