Rendering Multiple Partials with Ruby on Rails

So, as we speak, I’m going through a bit of the code that I’ve submitted for the OLM project, and I’ve begun refactoring.

While doing this, I ran into an interesting problem:  I want to use Rails’ remote_function to update two sections of the page with an AJAX call.  For a while, this stumped me, because you can really only have one render call within a controller method, like this:

render :partial => "footer"

But I was determined to render two.  So here’s what I ended up doing:

On the client side, I’ve got this in my view…

<%= remote_function (:url =>{ :action => "codeviewer", :id => @assignment.id, :uid => @uid },
                   :with => "'fid='+fid", :after => "$('working').hide();")%>

And in the Controller, in the “codeviewer” method, I do this:

render :update do |page|
    page.replace_html 'codeviewer', :partial => 'codeviewer', :locals =>
        { :uid => params[:uid], :filetext => filetext, :annots => annots}
      #Also update the annotation_summary_list
    page.replace_html 'annotation_summary_list', :partial => 'annotation_summary', :locals => {:annots => annots, :fid => @fid}
end

This will render my two partials in the DOM elements with ID’s ‘codeviewer’ and ‘annotation_summary_list’, respectively.

Nice.

Mike’s Tips for Falling Asleep

Last night, I had a pretty hard time getting to sleep.  This is not a new phenomenon to me, and I doubt I’m alone.  I’ll bet you (yes you) also have trouble getting to sleep sometimes.

So I thought I would share some of the techniques I use for falling asleep.

By the by, I’m clearly not a doctor, and this is by no means a definitive sleeping guide – but these tips seem to work for me.

Here we go.

Tip 1

I try to avoid consuming caffeine and large amounts of sugar within an hour or so before sleeping.  That means tea, chocolate, coffee, cola, sugary cereal, etc.

That’s just common sense.

Tip 2

Write down everything that I need to do for the next day.  That way, I’ve reassured myself that I’ll deal with those things when I wake up, and I can allow myself to let them go in the mean time.

Tip 3

Turn my computer off.  I actually feel muscles in my body relax when I hear it power down.  When my computer is on, I’m alert and thinking.  When it’s off, then I can sleep.

Tip 4

If I’m lying in bed, and I can’t fall asleep, it makes me tense.  Nothing is more frustrating in the night than insomnia, and that frustration usually manifests in me as muscle tension, which keeps me awake.

It’s a vicious cycle.

So, if I’m lying there in bed, all frustrated, I usually ask myself this question:

Is my face all scrunched up?

I’m surprised at how often the answer is “yes”.  And how can I go to sleep with a lemon-sucking face?

If my face is tense, no doubt other muscles in my body are tense.

Here’s a lesson that took me 2 years to fully realize:

The easiest way to relieve muscle tension is through breath.

I know, sounds crazy, but it’s true.  Here’s how I can prove it to myself:  Go into any stretch as far as I can go.  Hold it.  Now inhale and exhale.  I can usually go down quite a bit more by “riding” the exhale.  Hmph.

So, anyway, if my face is tense, probably other parts of my body are tense.  I try to do a full inventory of these muscles, starting from my toes, up to the top of my head, figuring out what’s tense.  If I can’t ease the tension with breath, I give it a good ol’ massage.

Tip 5

I cannot sleep without a clear head.  There have been so many times that the only thing keeping me awake was some crazy idea, or a song, or a solution to a problem, etc.

For me, what helps to calm down my overactive brain, is to force myself to only concentrate on one thing.

This is a lot harder than it sounds.  It takes practice, and there’s plenty of time for practice if you can’t sleep!

Here’s how I clear my head:  I try to picture a black circle on a white background, or a white circle on a black background (some nights, one is easier than the other.  Strange…).  Then, I just focus my hearing on my breathing, and just focus on breathing in and out.

I try to let myself become absorbed with the act of breathing – trying to find the nuance and uniqueness of every inhale and exhale.

And usually that’ll do it – next thing you know, my alarm clock will be going off, and I’ll be hauling myself out of bed.

Does anybody else have any sleeping tips?

Cesar Salad in my Satchel – A Cautionary Tale

There’s a little cafeteria at Innis College that I like.  My favourite menu item is BBQ’d chicken on rice with a Cesar salad – only $5.50!  It’s a lot of food, and it tastes great.  I usually get some on Mondays.

Today is Monday, and I took my meal to go.

And put the solid-looking plastic clam shell container in my satchel.

A brisk walk later, I sit down in the Playhouse lobby to enjoy my delicious meal.

I reach down and pick up my satchel, unclasp the top…

and there’s Cesar dressing everywhere.  More dressing than I thought could possibly cover a salad.  It was absolutely incredible – like a white paint can had exploded in my bag.

Have you ever had your faux-leather wallet dripping with Cesar dressing?  You don’t want to.

Yech.

Anyhow, the meal was delcious, despite the Cesar salad debacle.  I highly recommend that little cafeteria.

Just wanted to share that.

MyTTC and StopFinder

So maybe everybody else in Toronto knew about these mashups, but I sure didn’t.

Until this afternoon.

So here’s some free publicity for them…

MyTTC

New to Toronto?  Intimidated or confused by the Toronto Transit System?

If you’ve tried the actual TTC website, you may find it confusing, and lacking in beginner information.  You just want to know how to get from point a to point b.

Enter MyTTC.  Just give it your starting and finishing location, and the hour you plan to leave, and it will plot you a trip through the TTC, lickity split. Google Maps style, with instructions on where to board, and where to get off.

I could have certainly used this during my first year here.

StopFinder

Tired of paying too much for parking?  Think you’re getting ripped off by sketchy lots?  Wouldn’t it be nice to get a good look at the entire “parking” picture of Toronto?

Check out StopFinder.  Just give it your destination, when you intend to arrive, and for how long, and it will show you the nearest lot, the cheapest lot, and all of the other options in the area.  Also via Google Maps.

Cool and useful mashup.  I like.

Memorizing My Lines

In all of my performance classes, without fail, I’ve had to memorize lines at some point or another.

This year, in Voice class, I had to memorize an edited version of JFK’s “We go to the moon” speech.  I was the one who edited it, and it came down to about a little over a page of text.

And I memorized it, fluidly, in about 3 days.  Not bad.

So, here’s how I normally go about memorizing my lines:

  1. If there is an original recording of the speech, or lines in question, avoid it at all costs.  Do not taint your performance with someone else’s interpretation.
  2. Understand the text.  This is the most important part.  What am I saying?  Why am I saying it?  Who am I saying it to?  Why do they care?  Why do I care?  What is causing me to speak?
  3. Examine the text for clues.  What is the key word, or idea in each sentence?  Look for rhetorical devices, like metaphor, repetition, etc.
  4. Break the text into “argument” sections.  These are usually just paragraphs.
  5. Record myself speaking the lines, without any “acting” – just speaking them normally, and adding the appropriate pauses and breaks for punctuation.
  6. Break that recording up into the argument sections, and put the individual files on my MP3 player in speaking order
  7. While I’m walking in between classes, play the sections.  Listen to myself, pretending I’m the audience.  Ponder how to deliver what I’m hearing.  Ponder how to deliver any rhetorical devices.
  8. Start to speak the lines with the recording.  For me, this is the kinesthetic learning bit.  My mouth and lips learn the “dance” of the speech, so that if I happen to forget a line, my mouth and lips know where to go for the next line, which may remind me what my next line is (understanding the logical structure of the argument also helps to pull out of forgotten lines – if I need to get from A to C, of course I need B…)
  9. Repeat repeat repeat.  Keep playing the MP3 player, and speaking the lines to myself.  Go section by section.
  10. Play the MP3 player even when I’m working on other things, so that it’s playing in the background.
  11. Sleep (without the MP3 player playing).  It’s amazing how, in the morning, all the stuff that I’ve been repeating in my ears and with my mouth is still there, and comes faster and naturally.
  12. Now I’m ready to try to rehearse this thing.  If I have scene partners, I get together with them and just give it a shot.  If I’m doing a solo performance (like with the JFK speech), I try delivering it aloud to an audience of friends.
  13. Practice practice practice.  Rehearse.  Don’t get stuck in a delivery pattern.  I try new things:  I dance the speech, yell the speech, whisper the speech, seduce with the speech.  I get playful.  I put the story of the speech at higher priority than my performance; what is absolutely necessary is that the message/story gets across.  The “acting” is secondary.

And that’s how I do it.  Nothing special, and it works for me.