I’ve been in the getting a kick out of reusing lots of code lately. Finding ways to keep DRY has been quite a rewarding experience. A few days ago I learned about the polymorphic_path Rails helper. This helper makes things a lot easier when you’re trying to reuse a code either in the view or controller of a given resource.
An example for this is having a shared partial that includes action buttons for a resource (eg. edit/show/delete). You realize that you have these action buttons across a few different resources. A good way to DRY this up is by creating a shared partial for these resources.
So something like this:
Would turn into this:
Doing this will allow you to use the partial for many different types of resources if they have those actions available.
And in case your resource is nested then you can simply add the parent resource (or namespace) like so:
More info about polymorphic routes can be found here
My new years resolution for 2013 was to learn Ruby and Ruby on Rails. I had attempted to do so previously, but I never really got far. I had a lot of trouble initially getting my computer set up. I initially started with the Lynda.com Ruby on Rails tutorial, but it was a bit dated and I couldn’t really find a way to complete it. It wasn’t until I started on Code Academy’s Ruby course that I started to understand the elegance and expressiveness of the language. This was when I started feeling a need to work with Ruby on a daily basis. I knew I needed more. I started going through Michael Hartl’s Ruby on Rails tutorial. It was truly great and after going through the book something became perfectly clear: Ruby and Ruby on Rails is a space I want to be in.
Over the last few months I have been spending a lot of my free time learning all I could about Ruby and Ruby on Rails. I’ve built a couple apps and even cloned Reddit. I’m in the middle of building an app that incorporates all that I’ve learned. I thought it was important to use TDD as much as possible. So far, I’ve been really enjoying the whole Red Green Refactor thing.
Building apps for fun is all well and good, but I’d like to build something useful. I’d like to build something that others could use even if just a few times a month. The app I’m currently working on is in the early stages, but I’m really looking forward getting it out to friends to see if and how they use it.
Earlier today I read a few articles like this one and I must say, I don’t quite understand all these people talking about how Apple is in trouble and that their stock is so disappointing. Regardless of how people feel about their products there is no denying that they are a super successful company.
And for people who are saying that “apple is in trouble if they don’t invent a brand new product soon” must remember there was a six year gap between the iPod and the iPhone. And a 2 year gap between the iPhone and the iPad.
They make more profit on their computers than all their competitors combined! Yet, they don’t have huge margins like the rest do. Don’t believe me? Here’s a chart:
So why are sites like Mashable doing this?
Because the media loves Apple drama!
All I know is that if I could invest in Apple back in the day, I would.
“Give up on yourself. Begin taking action now, while being neurotic or imperfect, or a procrastinator, or unhealthy, or lazy, or any other label by which you inaccurately describe yourself. Go ahead and be the best imperfect person you can be and get started on those things you want to accomplish before you die.”