Friday, November 22, 2013

How to solve “undefined method `title' for nil:NilClass” in Rails Tutorial

If you are following http://guides.rubyonrails.org/getting_started.html or similar, you may get the awful  “undefined method `title' for nil:NilClass” problem. In that case, just go over to app\controllers\post_controllers.rb and put all "private" headers at the bottom. For example, if you have,

private
      def post_params
        params.require(:post).permit(:title, :text)
      end

which you should, as it's part of the tutorial, then make sure this block, and any others that say anything about being private, as far down the column as possible. Here's how mine ended up looking afterward:

class PostsController < ApplicationController

    def new
    end

    def create
      @post = Post.new(post_params)

      @post.save
      redirect_to @post
    end

    def show
      @post = Post.find(params[:id])
    end

    private
      def post_params
        params.require(:post).permit(:title, :text)
      end

    end

--
Condensed from: http://stackoverflow.com/questions/17810348/undefined-method-title-for-nilnilclass-rails-guides-tutoraial

Tuesday, November 19, 2013

How To Use An Oven to Save A Water-Damaged iPhone

I've put my iPhone in the oven two times now, all in the name of saving it from water damage. It's worked perfectly both times with no adverse affects.

Please note, I take no responsibility if something goes horribly, horribly wrong with your phone. I've used this on my iPhone 4. Here's how.

Get a container you can put in the oven (glassware is great.) Put a bunch of rice in there (enough to cover a phone.) Turn off the iPhone (doesn't matter if battery is charged or not, I've tried it both ways), and make sure to take off any case (except those clear sticker cases, which are ok) and stick the iPhone in there so that it is completely covered in the rice, INCLUDING ON THE BOTTOM. You do not want your iPhone touching anything but rice. I suggest white rice, but not sure if any other type would be bad. This will prevent the hotter-to-the-touch glass from contacting the phone.

So stick your phone in the oven and turn it on. I have used convection and normal bake modes. Honestly I think the convection method worked better. If you don't have that, the normal mode should be ok. Set it to the lowest temperature, which is for me 170 degrees. I'd suggest not over 180. 200 is an absolute keep-your-fingers-crossed maximum, for my money.

How long? I'd say increments of 20 minutes. Once I forgot it and it was in there for 40 minutes straight. No worries, but stay on the safe side. Just check it out, make sure battery acid hasn't exploded everywhere (or, that it's not TOO hot to the touch; it should be kinda hot like you left it in the sun a long time, but you should still be able to handle it.) Unless you dropped it in the toilet or some other embarrassing thing, the phone should be good to go after 20 to 30 minutes, depending on convection methods etc.

How do I feel comfortable doing this?
I have been in the sauna at the gym before, where it gets up to 180 degrees. The worst thing that happened is my phone showed a exclamation point warning and locked the phone until it cooled down. For the iPhone in oven method, just turn it off, then wait for it to cool down before using.

To cool down your phone: DO NOT stick it in the freezer or refrigerator. There be moisture in there. You can let it cool down on its own, or take it in your hands and let the heat transfer away to you.

Why rice?
Rice has natural drying properties. Some water damage phone guides say to use only rice, but that is unnecessarily long.

The problems I solved with my phone:
One time when it was really damaged and showed only some strange blue screen with garbled colors.
Another time (today, actually) when it was possessed (by water), and it was doing all sorts of random home-button functions (mostly sending me to Voice Control or whatever it's called.
 

Any questions, I'm happy to answer.