rails 2.2.2 active scaffold foreign key 500 error

September 2, 2009 by hillemania

I was trying to get active scaffold running under rails 2.2.2 today and kept hitting a bug.  Every time I changed one of my model relationships to include a foreign key I would get the appropriate form fields in my views, but they would always give me a 500 error.  After much wasted time I finally looked at my server prompt and saw that there were some depricated calls.

Here is the fix which is pretty much spelled out in the calls, but in case you want to know.

go to /site/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb

search for these 2 lines

if override_show_column_ui?(column.column.type)
send(override_show_column_ui(column.column.type), column, record)

in both of those lines change the “type” in red to “class”, your new lines should look like this

if override_show_column_ui?(column.column.class)
send(override_show_column_ui(column.column.class), column, record)

that did the trick for me, now everybody is happy!

I doubt anyone will read this, but I have one other post that I didn’t think anyone would read and it seems to have helped several people.

TweenSequence, a TweenMax utility for tiered animations

April 6, 2009 by hillemania

TweenMax is fantastic, TweenGroup is great, TimelineMax is even better than TweenGroup.  With all that said there is one very useful feature that I felt it was missing.  The inspiration from this came from a brilliant animation system that my co-worker created a few years back.

When working with large multi-tiered animations I often find it tedious to use TweenMax, especially if you need to pull out or add animations in the beginning or middle of a set after the fact.  Sure you can use TimelineMax to create a huge set of animations that start one after each other, which is great, but often times I have 2 or more animations in the middle of a sequence that need to fire at the same time.  You can work with TweenMax, TweenGroup, or TimelineMax to get this to work, but it often requires managing a bunch of delays that become very tedious.  There are other methods but they require writing too much code for something I think should be simple.

After several attempts at a solution I finally decided that I would extend the TimelineMax class.  This is still in beta, but the tweenMax guys have said that they’ll be deprecating TweenGroup so I figured I’d build for the future. One advantage of extending the class is that you still get all the functional goodness of the original class with one new function.

Below is a code example:

var anim1 = new TweenSequence();
anim1.add(clip1,1,{y:300},”set1″);
anim1.add(clip2,1,{y:300},”set2″);
anim1.add(clip1,1,{y:0},”set3″);
anim1.add(clip2,1,{y:0},”set3″);
anim1.play();

Hopefully this is pretty straightforward, but this is how it works.  You now can use your TweenSequence object just like a TimelineMax object, but with the new “add” function.

TweenSequence.add(object,duration,{TweenMax paramaters object},setName);

The additional setName should be the only thing looking unfamiliar to those of you used to TweenMax.  What TweenSequence does is keep track of sets in the order that you define them.  The name of the set is unimportant, only the order of the first defined animation assigned to that set.  It then runs all animations of each set to begin at the same time, and then all animations of the next set will begin at the end of the first animation of the previous set.

Ok, that probably sounds a bit confusing, so lets just show an example.

anim1.add(clip1,3,{y:300},”set1″);
anim1.add(clip2,5,{y:300},”set1″);
anim1.add(clip1,5,{x:300},”set2″);
anim1.add(clip2,3,{x:300},”set2″);
anim1.add(clip1,3,{y:0},”set3″);
anim1.add(clip2,3,{y:0},”set1″);

In this example the first set of animations that will run will be set1.  This even includes the very last animation added in the code as it’s still defined as belonging to set1.  All of the set1 animations will begin at the same time.  Next up is set2 which will begin 3 seconds after set1 starts.  At this point you might ask why doesn’t set2 start 5 seconds later as the second animation in set1 will overlap into set2. The answer is simply personal preference.  This is the way I like it to work, and it’s easily fixible by just defining your longest animation of a set first.  By using this method you are able to avoid or allow overlap at your discretion.  Finally set3 will run 5 seconds after set2 starts as the first set2 defined animation is 5 seconds long.

So that’s it, pretty simple, but a handy and concise way to create a complex multi-tiered animation.  If it seems limited just remember it’s still a TimlineMax object that uses TweenMax tweens, so you can use the power of those to take this well beyond simple tiered animation.

This is a AS3 class, would be simple enough to make it a AS2 class but I really have no need for it right now.

It also could probably use some polish or be compacted, but again those aren’t things I’m concerned with.  I’m going to try and submit this to Jack over at GreenSock and see if he’d think the concept was useful for a future release.

In the meantime enjoy.

Download the code here http://hilleman.net/TweenSequence.as

Before using this make sure you have the TweenMax v11 beta, otherwise it’s not going to work.

UPDATE: After sending this over to Greensock(Jack), it looks like he’s going to implement an improved method into a near future release of his TimelineMax system.  It will be an improvement over my idea, fit into the existing syntax, and be more flexible, win for everyone.

UPDATE TO THE UPDATE:  Jack over at greensocks let me know that newest version of the beta now has the functionality built in.  This is the way it works.

var myAnim:TimelineMax = new TimelineMax()

myAnim.insert(TweenMax.to(blahblah),”set1″)

myAnim.insert(TweenMax.to(moreblah),”set2″)

etc..

The basic way it’s setup is if you insert a tween at a yet undefined set id then it will automatically create a new set at the current duration.  This is great because it’s less code, intuitive, and flexible as it allows you to use tweenMax or TweenLight

Passenger for Rails, wow, really, wow!

March 5, 2009 by hillemania

So I know I’m way way behind the times here but I just heard about passenger today from a co-worker.  I haven’t really done much Rails for the last year and so I’ve been really out of the loop.  Then my friend tells me about passenger.  It’s an Apache2 module that allows you to deploy rails site like php sites, by simply adding vhosts. All you have to do is install the passenger gem, then run one passenger command which installs the module in apache as well as gives you the appropriate config lines to put in your httpd.conf file.  Then you’re ready to go, just make vhosts to the public directories of you rails sites.  I tried it on my mac this morning and within 2 minutes I was up and running.  I can’t believe how many hours I spent trying to setup fast_cgi, mongrel and other options through apache.  I finally did get a mongrel cluster running once but it’s such a pain.  This makes it all so incredibly easy.

iMovie 09 themes, marketing ploy?

February 6, 2009 by hillemania

So one thing that looked incredibly cool in the pre-release videos of iMovie 09 were the themes.  They were incredibly dynamic high quality looking sets of transitions for your movie.  My first impression was “these look cool”.  I also wondered how many there were, surely there would have to be quiet a few or at least quite a few frameworks that you could edit, swap out graphics etc.  Sadly when I got iMovie I found that there are only 6 themes, and so far it doesn’t look like you can edit it.  It’s like taking somebody elses editing and just swapping out part of the content.

Now many people are probably thinking that I’m just being a negative Nancy about all this, and maybe I am.  I don’t want all my movies looking the same.  So that pretty much leaves me with 6 movies I can apply a theme to if I want, and then I’m out of themes.  I guess I wish there was more customization available for the themes.  They’ve obviously had to put a great deal of time into them to have them work so well, so why not give them some legs to be more flexible.  I also realize that making something editable can be a huge undertaking, and I imagine that’s the case here.

In the end I think that I was mostly disapointed with the amount of attention they were given in the promo pieces. This was obviously done because they make great eye candy for the product and you can’t blame them for showing off the pretty side of thing.  I suppose I felt with that attention there would be more behind it.

It’s no big deal breaker, I’m still enjoying iMovie thoroughly and would recommend it to anyone.  I’ll just have to wait longer for my custom amazon comic book theme.

SmartFoxServer is cool

February 5, 2009 by hillemania

So for a year now I’ve been wanting to mess around with multi-user connectivity in flash.  I knew there were several products out there and I just hadn’t had time to mess around with any of them.  Over the last couple weeks I actually have had some time to experiment and it’s been very enjoyable.  The first step was to assess what types of things I needed.  I was mostly interested in messaging and the sending of small images.  The flash media server seemed to be mainly geared at video and audio streaming which I didn’t care about.  Red 5 was pretty much an open source version of that.  I found a cool little app called socketserver made by Richard Shields.  It was a very nice simple to setup socket server that allowed communication between multiple flash apps.  It’s mainly designed as a messaging system that basically blasts out any incoming message to everyone who is connected.  If you’re looking for a simple chat server then it’s a great service, but I needed a bit more.

I then went through a few of the commercial options and ended up choosing smartfoxserver.  It’s socket server for flash among other interfaces that allows messages and data to be transferred to clients.  It supports zones/rooms a buddy system and several other chat community type features. One of the major advantages was that is has an OSX server, which makes developing much easier on my mac.  Getting things up and running has been pretty smooth.  If you are using the AS3 then you might find everything but the API docs to be kinda useless.  So far there seems to be much more support for AS2, but once you figure out how everything works it’s no big deal.

So far I’ve found the server to be stable and easy to monitor.  It comes with a handy flash admin interface with nice visuals, looks much better than most server admin interfaces.  I have found some issues with sending large objects, mainly a byteArray representing a user pic, but I got around it using a method my friend used by converting the byte array to a base64 encoded string.  I haven’t flushed out that whole issue yet, but I’m assuming there was some limit on the object size and that by encoding it I was able to get it under the ceiling.

So for right now smartfoxserver has served me well and I look forward to continuing to work with it.

iMovie 09 first impressions

February 4, 2009 by hillemania

I mentioned in the last post about working with iMovie 09.  I thought I would post some impressions for those of you who might be looking for initial thoughts and somehow would possibly find your way to this dusty corner of the web.(yes I do know the web doesn’t have corners just go with it)

Prior to this version I had used both iMovie HD and 08.  I wasn’t into doing much video editing before 08 came out so that was my first iMovie experience.  Before that I had used a variety of PC programs and thouroughly hated them all.  They were sluggish, difficult, and just plain buggy.  I loved the the 08 interface, it just seemed to be very straightforward and easy to use.  I know some hated it, but I loved it’s clean simple nature.  At first I thought it was going to turn me into a movie editing maniac, and I jumped right in.  After creating a couple videos I started realizing it’s limitations.  The more I did, the more I wanted to do, and it seemed like there just weren’t many things to do in 08 besides slam a few clips together with some transitions.  I then started mucking with HD as it seemed to have many of the simple effects that I wanted, but it lacked other features like the ken burns effect etc that I commonly used in 08.  In the end I became frustrated with the 2 programs, between them there seemed to be all I needed, but jumping back and forth seemed way too annoying for me.

When I heard about 09 I just crossed my fingers and hoped for the best.  The initial features apple announced made me very excited, and the more I heard the more I liked.  So now to my actual experience.  09’s interface is very similar to 08, a big plus in my book at least.  The drag and drop and moving around functionality is all there, but what’s better is that there is the optional precision editor which takes you back to a more HD like interface for fine tuning.  It’s like the best of both worlds.  The ability to extend one clips sound track beyond the video and into the next scene is fantastic for multiple angle shots, or when splicing something in the middle of a section.  The camera stabilization, green screen support and other overlay techniques are very very cool, still trying to get my green screen room and lighting perfected, but just having the option is great.  The new text animations are incredible, this doesn’t look like a home movie anymore, it’s cinema quality.  One thing that seems to be a little worse is performance, I’m not a 100% sure on this but so far it seems to bit a bit chunkier than than 08.  To be fair I’m using some larger clips in my first full video which I know will hurt the performance, but I just remember 08 feeling smoother overall.

As far as features go I think 09 has everything that I wanted save 1 not so minor feature, an audio rubberband.  I really don’t understand why there is no rubberband, HD had one, and they support complicated stuff like auto ducking.  Why not give us a rubberband, it would be so useful!  If I want to fade out the audio at the end of a track I get at most 2 seconds to do it in, and that is horribly limiting.  Luckily most of the audio leveling that I want to do pertains to soundtracks so I guess I can go throw them in garageband and handle it there, it’s just more of a pain

I’ll probably post more once I get through a couple projects and really get a feel for more of the features, but as for right now I’m lovin it, and not in a McDonalds breakfast kind of way.

Splitting Quicktime .mov files

February 2, 2009 by hillemania

I got the iLife 09 suite last week and I’d have to say I am most impressed with the new iMovie.  I was a big fan of the iMovie 08 interface but it lacked so many crucial features that it pretty much drowned out my desire for creating videos.  Now with 09 bringing back almost all of the powerful features of iMovie HD(don’t get me started on the rubber band audio omission) my excitement for creating videos is higher than ever.

As a first project I’m going to attempt to do a comical remake of Star Wars Episode 4 starring my 5 year old son and 3 year old daughter.  It’s going to take some experimenting to get a good green screen environment, but it should be very fun and the kids will love the final outcome.

One issue I’ve had early on while creating it was working with the original star wars movie.  I used handbrake to rip a copy from my DVD, but it’s in one big chunk and when you are trying to work with a 1.6GB 2 hour movie as a clip in iMovie it’s a pretty laborious task.  So I figured wouldn’t it be nice if I had the movie split into several 5 minute pieces so it would much more maneagable.  I figured this would be an easy task, which is was in the end, but finding the right tool took hours.  My first thought was that there might be some sort of event splitter option in iMovie, I couldn’t find one, I then tried my free movie editing tools like ffmpeg and streamclip, I was able to figure out ways of editing out sections, but it was a complete manual affair that required re-encoding and was going to take days upon days to render everything out.  I then started looking in the horrid crapware space on the web and found a couple windows apps that looked promising, but were not.

I then started wondering if I could use QT pro to do the trick, it looked like some people had written scripts, but none of them seemed to be what I wanted exactly and I also don’t have a license for Pro.  Finally I stumbled upon the most amazing little tool.  It’s call QTCoffee and the website is here, it’s incredibly powerful, fast and free for non-commercial use.  It doesn’t require any other software and did exactly what I wanted.  Want to split your movie into 20 pieces, no problem, want to split it into 5 minute sections, no problem, want to split it on encoded chapter points, NO PROBLEM!   Yes, it’s as good as it sounds, as long as you don’t mind using the terminal window and not having a gui, which is pointless when something works this good.  Now even though it is free I would highly recommend that you chip in a donation, this thing works better and faster than any of the paid products that I tried.  3AM software devs, you guys are the real deal.

Now back to transforming my son into Luke Skywalker

AS3, gotta love it, most of the time

January 30, 2009 by hillemania

I’ve finally begun to transfer over fully to using AS3 now for my flash coding.  I know it’s a little late, but our company has some frameworks we’ve developed based on AS2 which have kinda kept me back.  That and the fact that we have a very mixed group of Developers and Designers makes an AS3 transition more difficult.

First off I completely understand how most Designers would hate AS3, it’s very different than AS2, not the scipting language of it’s predecessor, but more of a fully realized robust OOP language.  On the flip side looking at it as a Developer that difference is nothing but good news.  I will admit, after years of AS2 entrenchment my immideate response was a litte like, “This seems harder to do simple stuff”.  In the end it’s not really harder, but often seems like I do write more lines of code for most things than I did before.  While I love minimalistic practices, I also am a huge fan of structure.  So even though I’m writing more lines of code nowadays, the structure is miles beyond the old methods I used.  I’m finding myself thinking like a programmer and not a scripter, and that has been exteremely enjoyable.

No more frame code, no more massive lists of functions that control all sorts of items.  I’ve given up on putting any code in .fla’s.  Now it’s all in external class files.  At first I thought that might be a pain, and hard to keep track of, but I was completly wrong.  My code might be spread across several files, but now it’s organized and is divided into logical classes.  It’s so much easier when you can just go look at the code for the portion of your app that you are interested in rather than constantly working around non-relevant functions.

I know that this same approach could have been done in AS2, it’s just that it didn’t seem like there was as much a benefit from going down that road before.  AS3 just seems to be made for this.

I’ve had struggles and frustrations which I will no doubt bring up in future posts, but I would have to say AS3 has renewed my passion for coding and made going to work a much brighter affair.

Back again, yes, again again

January 30, 2009 by hillemania

Well I’m once again going to try and start blogging.  This time with yet another approach to the whole idea.  Before I was kinda trying to keep the whole process focused on Techincal issues, programing or otherwise related.  I found making a technical post to be fairly daunting as you need to make sure you don’t lead someone down the wrong direction and make their predicament worse.

This time my experiment is to just blog on anything at all.  I’m a huge computer/gaming nerd so I’m sure my posts will most likely be slanted towards the technical, but I’m also a dad 3 times over so the stories of fatherhood make sneak in as well.

I fully expect this to fail like all the other attempts, but I guess “try try again” must be built into nature.   Here’s to staying consistent, cheers!

The Rails experiment

October 11, 2007 by hillemania

Alright, I’ve been M-I-A for quite some time now. That’s pretty much the norm with having little kids. I am however on the very tail end of a fairly large project that I started last spring. I’ve learned an incredible amount from the process, things I would do again, things I wouldn’t do again.

I’ve also been able to stretch my Rails muscles and begin to incorporate more of what rails has to offer into my knowledge base. It’s been very exciting as there have been many ah-ha moments where I realized that I had just discovered something that was going to save me alot of time in the future.

In the end I came up with an idea for future projects. This has been sparked by my exposure to the CMS system Drupal. I work with a guy who has become very fluent with Drupal and that’s become the platform for his web projects. I’ve spent some time with the system, and while I do see some of it’s advantage, I really can’t stand PHP. It’s just an awkward thing for me and it’s hard to get over that. One thing I seem to notice is that when you really want to make a custom site in Drupal what seems to be the most prevalent activity is trying to get something to do something it wasn’t exactly designed for. In the end this effort is usually seen as being worth it because of the additional functionality you get for free by using the Drupal framework.

Rails is more of a sandbox imo. You kind of start from scratch with a framework that allows you to rapidly develop apps.

So what I’ve decided to embark on is a kind of secondary layer of functionality for Rails. Things like user accounts, security levels, file managment, and basic CMS types of abilities would be part of this layer. I honestly don’t know exactly how it’s going to look yet, and maybe it will be a huge failure, but I want to try. The real premise is that there are several very common functionality types that I would like to have more flushed out from the beginning so that I could just use them instead of re-create them every project.

Here’s to a beginning, with my current track record look to see another blog post on this in 6 months ;)