Giant Japanese Robot

Better living through pop culture.
Feb 06
Permalink
Comments (View)

Feb 03
Permalink
Comments (View)

Dec 19
Permalink
Comments (View)

Dec 14
Permalink
agentmlovestacos:

New, awesome Shaun of the Dead photos w/@simonpegg, @nickjfrost and @edgarwright! Via @totalfilm, where they have more pics!

agentmlovestacos:

New, awesome Shaun of the Dead photos w/@simonpegg, @nickjfrost and @edgarwright! Via @totalfilm, where they have more pics!

Comments (View)

Nov 16
Permalink

Playing a lot of Borderlands with the spouse, so this is in my head constantly.

Comments (View)

Nov 12
Permalink

(via )

Comments (View)

Nov 04
Permalink

They Might Be Giants - Put It to the Test (via ParticleMen)

Comments (View)

Oct 31
Permalink

The Blob 1958 opening tune (via bubbazametti)

Comments (View)

Oct 16
Permalink

Ruby on Rails: String to Object

In my new app I have a whole bunch of nested models. For the most part they all have the same database structure and can use very similar partials. I hate to repeat code because it usually makes my life more difficult when I need to go back and change something or do maintenance. I am now placing these partials in a single location that all of these models have access to.

Problem is I had a very difficult time telling the partials what object it needed to represent without adding a parameter. (I am making a lot of AJAX calls) I solved it by using the controller that was passed along with the request. After that I needed to take that string that was passed and transform it so ruby recognized it as an object. This was my final solution:

object = params[:controller].classify.constantize.find(params[:id])

Classify takes the string and gives it the proper camelcase format so that it conforms to the model naming convention. Constantize then takes that string and converts it into an actual object.

Comments (View)

Oct 14
Permalink

RIP Captain Lou. You will be missed.

Comments (View)

Oct 07
Permalink
agentmlovestacos:


Man, 2012’s gonna be IIiiiiiiintense!
(via 20twelve)

agentmlovestacos:

Man, 2012’s gonna be IIiiiiiiintense!

(via 20twelve)

Comments (View)

Permalink

Lenny Kravitz Let Love Rule (Justice Remix) (via lennykravitz)

Comments (View)

Sep 25
Permalink

Carl Sagan - ‘A Glorious Dawn’ ft Stephen Hawking (Cosmos Remixed) (via melodysheep)

Comments (View)

Sep 18
Permalink

Ruby on Rails: String to Boolean

Really, this should be simpler. Knowing Rails folks there is probably some deep philosophical reason this isn’t included, but I hold no grudge.

So….I’m converting objects back and forth to JSON and when they return all my pretty Booleans are converted into strings. My assumption was that there was a handy little .to_b(ool) method for String, but alas there does not appear to be. This is the method I ended up writing.

  1.      def object_to_boolean(value)
  2.         return [true, “true”, 1, “1”, “T”, “t”].include?(value.class == String ? value.downcase : value)
  3.      end

As always I am open to suggestions and improvements.

Comments (View)

Sep 01
Permalink

Ruby on Rails: Single Table Inheritance and Restful Routes

I am writing this out of a bit of frustration. I have a solution here, but it took too long and it can not be correct. I am hoping some smarter folks will chime in with some thoughts.

I have a model called Questions which has many subtypes using single table inheritance. Basically types of questions dropdown, checkbox, radio, etc etc.

These are set up as resources so I can use restful routing. I also want to use all of the rails form magic so I set up resources like this…

 map.resources :question_checkboxes, :as => :questions, :controller => :questions

This allowed the form_for method to render the form correctly and point to the “question” url instead of the url of one of the subtypes.

The next problem was that the “update” controller method was looking for very specific params “params[:question]”, but the rendered form was passing params like “params[:question_checkbox]”. The way I eventually solved this was set up a before filter and method in the controller like this…

 before_filter :form_symbol

   def form_symbol
      if params[:question] then @form_symbol = :question end
      if params[:question_checkbox] then @form_symbol = :question_checkbox end
   end

and then in the update method of the questions_controller

 @question.update_attributes(params[@form_symbol])

It does the trick, but feels very uncomfortable. Suggestions and comments are welcome.

Comments (View)