Archive for: April, 2008

undefined method `message’ for #

Apr 28 2008 Published by aaron under Programming

If your a seasoned Rails ninja, you might want to just skip this. However, if you have received this message in your rails application, the below might help you find what went wrong. This is by no means a end all solution, but I stumbled across this error just now and wanted to archive it in the case that I forget in the future.

This error came from an attempt of using the following code:

<div id="add_request_form">
<% form_remote_tag :url =>{:action=> :request_approval, :id=>@job.id },:update => 'request_history',
   :position => :bottom do  %>
    <label for="approver_request[message]" style="float: none; display: block; margin: 0, padding: 0; text-align: left;">Approval message</label>
    <%= text_area :approver_request, :message, :cols=>'60', :rows=>'7'%><br style="margin-top: 10px;" />
    <%= submit_tag "Request Approval"%>
<% end %>
</div>

<h4>Request History</h4>   
<dl id="request_history">

<% for ar in @approver_request do %>
    <dt>On <%= ar.created_at %> an approval request was sent to <%= User.find(ar.user_id).name %> (<%= User.find(ar.user_id).email %>)</dt>
    <dd><%= ar.message %></dd>
<% end %>

</dl>


Above, there is the code for sending a request for approving a job that has been entered into the web application. This code uses the remote_form_tag helper to allow updating the dl object without having to reload the page.

However, the above code will produce the error of "undefined method `message' for #<Array:0x23022d8>"  because you cannot share the same variable on the page when one of them is being used for submitting data!!

Here is what I ended up with:

<div id="add_request_form">
<% form_remote_tag :url =>{:action=> :request_approval, :id=>@job.id },:update => 'request_history',
   :position => :bottom do  %>
    <label for="approver_request[message]" style="float: none; display: block; margin: 0, padding: 0; text-align: left;">Approval message</label>
    <%= text_area :approval_request, :message, :cols=>'60', :rows=>'7'%><br style="margin-top: 10px;" />
    <%= submit_tag "Request Approval"%>
<% end %>
</div>

<h4>Request History</h4>   
<dl id="request_history">

<% for ar in @approver_request do %>
    <dt>On <%= ar.created_at %> an approval request was sent to <%= User.find(ar.user_id).name %> (<%= User.find(ar.user_id).email %>)</dt>
    <dd><%= ar.message %></dd>
<% end %>

</dl>

No responses yet

Remember VI

Apr 18 2008 Published by aaron under Programming, Sysadmin

This is really just for myself to have a reference for using the text editor named VI. Your welcome to use it yourself, perhaps I will make a PDF later to help me cheat more :P until then, on with the non-sense commands:

looking for text

  1. when looking for text and your cursor is on the word you want to search for, use the * character to search for the pattern going forward in your document
  2. setting the "incsearch" option will show the first match or the pattern while you are still typing it
  3. setting the "hlseach" option will highlight all of the matches in the document when searching

moving around

  1. use % to jump from open brace to its matching close brace or from open if statement
  2. at the end of the brace or if statement, use [{ to jump back to its start of the {
  3. use gd to jump from the use of a variable to its local declaration

macros and repeating

  1. to make a macro:
    1. type "qa" to record into register "a"
    2. do all yer commands
    3. type "q" to stop recording
    4. to repeat the macro, enter number of times to repeat, then "@a"
  2. also, the "." will repeat any command you previously execute

No responses yet

How nuts and bolts are made

Apr 15 2008 Published by aaron under Fun, Video

I like this video that shows off how nuts and bolts are made! Crazy to see the process, tools, and amount of time needed to create just nuts and bolts!

My favorite scenes are the nuts flying out while the are red hot.
Update: the video has been removed based on copyright issues :/

Embedded Video

Blogged with the Flock Browser

No responses yet

Untangaling my phone cord super fast

Apr 15 2008 Published by aaron under Organization

Your looking at that spiraled phone cord that has all of those loops (or extra twists,.. not sure what to call them) and its just making your phone look really messy, and your thinking "there has got to be a way to get all of these out faster than just letting gravity do the trick". These loops are taking up valuable stretching lengths! Also, they start to grow in numbers each time they appear. Here is one of mine:

So you might be asking "how do I fix these things!?"

First, the legal clause part:

I full admit that there is possibly a better way to do this, and I am not going to buy you a new phone cord if you ruin it. I have not ruined mine.

My solution...

which does involve unhooking only one side, without any "hanging", "gravity-will-fix-it", and its quick to complete :D

Here is the basic outline:

  1. read all of the steps before starting your untangle
  2. refer to pictures for more information
  3. detach one side of the phone cord (best to start with end closest to the extra twist)
  4. take the jack and feed it in to all of its loops until you get to the extra twist
  5. now get firm hold of the jack side in one hand
  6. get firm hold of the extra loop in other hand
  7. pull until its flat

Here are some visual pictures for better explanation:





18 responses so far

Flying in SecondLife with body motion

Apr 15 2008 Published by aaron under Video

I found this video about how you can use a 3D camera to capture your body motions and manipulate your character on SecondLife. I also found another piece of technology that will project SecondLife characters in 3D onto objects. This might be an interesting future for the home in about 10 to 20 years. Where we will interact with each other between two or more distance locations.

No responses yet

Older posts »