Lenny Kravitz Let Love Rule (Justice Remix) (via lennykravitz)
Lenny Kravitz Let Love Rule (Justice Remix) (via lennykravitz)
Carl Sagan - ‘A Glorious Dawn’ ft Stephen Hawking (Cosmos Remixed) (via melodysheep)
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.
As always I am open to suggestions and improvements.
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.
Following post is for Ruby on Rails geeks.
I don’t normally post my programming adventures here, but maybe I should. This is a simple thing and should have been obvious right away to me, but it wasn’t so I am posting it here for future generations. Thanks to Geek Mama for shaming me into posting this.
I have a “has_many :choices, :through => :question_items” model set up for Questions and their Choices. The QuestionItems model also has a”position” column because it is an Acts_As_List model. All is fine and good until I try and get the choices to return in the correct order by calling @questions.choices in my controller.
The solution was pretty simple, adding an :order option to the has_many method solved it:
has_many :choices, :through => :question_items, :order => "question_items.position"
nouvelle vague “dance with me” from bande a part (via luakabopper)
Tricky Linguistics (via ayesham819)
(via reygunn)
Quirk Classics #2: Book Trailer (via irreference)
Bionic Woman - Bigfoot (via LincolnAP)
Checklist
Interview with Danny from The Shining (via Spiralendrache)
Bollywood He-Man
Bonus dime store Orco.
Chahiye He Man He Man from Nafrat Ki Aandhi (1989) (via jatholb)
From Wikipedia:
In December 1974, a French consortium led by Jean-Paul Gibon purchased the film rights from APJ. Alejandro Jodorowsky was set to direct. In 1975, Jodorowsky planned to film the story as a ten hour feature, in collaboration with Orson Welles, Dan O’Bannon, Salvador Dalí, Gloria Swanson, Hervé Villechaize and others (whom he nicknamed his “seven samurais”). The music would be composed by Pink Floyd. Jodorowsky set up a pre-production unit in Paris consisting of Chris Foss, a British artist who designed covers for science fiction periodicals, Jean Giraud (Moebius), a French illustrator who created and also wrote and drew for Metal Hurlant magazine, and H. R. Giger. Moebius began designing creatures and characters for the film, while Foss was brought in to design the film’s space ships and hardware. Giger began designing the Harkonnen Castle based on Moebius’ storyboards, and Dali was cast as the Emperor with a reported salary of $100,000 an hour. Jodorowsky also hired Dan O’Bannon to head the special effects department.
I love the Lynch version but that would have been unicorn magic right there.