Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

Top 5 Rails Misconceptions

I have been working with Rails for almost 3 years now in a professional setting. During that time, I have had to convince many people of the merits of Rails. Here are the Top 5 Rails Misconceptions I have come across.

5. Rails is some sort of WYSIWYG editor for web pages.


This one has always baffled me. But, it is true. Every once in a while, I will meet someone that thinks Rails is like Dreamweaver. Huh? My best guess is that they read some buzz article about how "Rails makes building websites easy". Notice I said "websites". There really is no way to combat this misconception other than to just educate this person.

However, do not discount the fact that to many technology people the following is true.

web sites == web pages == GUI == web applications

In other words . . .

index.html == web page
amazon.com also == web page

And, it was probably developed with Dreamweaver.


4. Rails is AJAX.


Web 2.0 is AJAX. And, Rails is AJAX. So, make it AJAX'y. Maybe, this is because Rails started to get popular around the same time AJAX started getting popular. There might be some direct relationship between the two. But, regardless, I hear this one all the time.

Again, you really can't do anything about this except to try and educate. Usually, I try to explain that AJAX is a way to enhance the user's experience, and can be implemented with any number of web frameworks.

Hmmm . . . but, that explaination might be too "Web 2.0".


3. Rails can't scale.


You might be surprised to see that this is not #1. In all honesty, I almost never hear this argument from the people who matter to me (customers, clients and my bosses). I alway hear it from the IT/Ops team, or the DBA's, or the old school Perl/Java/C/C++/insert_whatever_lang_here programmer that sits down the hall.

How this is still an issue is beyond me. In any case, these are the arguments I usually use:

* There are really large Rails sites in production. Twitter (although be ready for the Twitter can't scale arguments), yellowpages.com, scribd.com, all the 37signals products.

* Scaling is usually a much larger architectural issue than just the web framework. Scaling involves hardware, OS's, caching, DB's, proxies, etc. Usually, the language matters very little in scaling.

* And, this is my favorite . . . every (I really mean EVERY) enterprise Java based web application I have ever worked on or implemented was slow as hell. Anyone want to back me on this one? So, what's the argument?


2. You don't need to learn Ruby to do Rails.

I think this early screencast of Rails almost did more harm than good.

http://media.rubyonrails.org/video/rails_take2_with_sound.mov

So, in this screencast, you see a young DHH creating a blog application in 15 minutes with Rails. Lot's of scaffolding and stuff.

Don't get me wrong. This screencast was one of the reasons I got into Rails. But, I thought the same thing. I just need to learn Rails. This is so false. Maybe, if you are creating a 15 minute Blog application, you just need to learn Rails.

This misconception is directly related to my #1 Rails misconception.


1. Rails is not programming.


This is definitely my #1 Rails misconception. I hate this one! Everyday, I have to fight this one.

So, how do I fight these misconceptions?

* Credibility. Be really good at what you do. As a Rails developer, don't be that person who just read the "Agile" book and thinks they can deliver. Read the "Agile" book. Then, you have to do much more . . . usually, this is in your free time.

* Productivity. Deliver quality faster than anyone else. Rails is great for this.

* Adaptability. Sometimes, you just have to make it work. So what if your company's legacy database is SQL Server with some jacked up composite-non-surragate primary keys? Make it work.

* Be nice. This one works all the time. Ruby, and Rails is threat to people. Don't come on like a threat.




Posted at on 9/24/08 by | 0 comments | Filed under: , , ,

Story Card Template for Agile Programming

Here is a story card template that my team will be implementing into our Agile Programming practices.  Feel free to use.

http://www.scribd.com/doc/5968484/Story-Card-Template

BTW:  Scribd renders the page weird in their Flash viewer.  If you download it, it looks fine.

Posted at on 9/12/08 by | 0 comments | Filed under: , , ,

Innovations in Ruby

Posted by the guys at RailsEnvy.com for a talk they gave at Ruby Hoedown. http://www.railsenvy.com/assets/2008/8/8/RubyInnovation.pdf

Some interesting things that I did not know about.

Posted at on 8/12/08 by | 0 comments | Filed under: ,

What you need in order to become a Ruby on Rails developer

I often get asked and see forum/blog post asking this question (or some variation of it):

"What do I need in order to start Ruby on Rails development?"

The following may not apply to all. But, face it. Admit it. There can be only one way. So, just follow this simple step to more joy and bliss. Here is the step to take. Yes, there is only one step.

Grow some balls


You need . . . To leave your crappy job. To admit that the technology platform you committed the last 5 years to is crap. To be happy about what you do everyday. To realize that the boss you hate really deserves it and doesn't deserve to continually make money off your efforts. To wake up and smell the Ruby.

Also, you need to stop drinking with your worthless "buddies". And, start spending some time learning Ruby, and Rails.
"But, but, but . . . those are my budz, my free time, my weekends . . . wha, wha, whahaaa".
Forget that! Those bums aren't going to help make you great. If that is your concern, then just stop reading now.

So, tell me about your balls growthage


"But, that's easy for you to say. I am in (insert some worthless excuse here) . . . blah, blah, blabbity, blah, blah . . ."


So, before you start thinking that I am just blowing smoke, here is my testimony.

I started in Java development. Became an expert in the IBM WebSphere stuff (when I started with it, it was all MQ this, MQ that). Grew into "Systems Architect", "Project Manager" . . . (insert whatever title you want here). Discovered it was boring as heck keeping track of people's hours and arguing over requirements with a client. Start to learn Rails. And, here's the key part. Wait for it . . .

I LEFT my job to do Rails. I took a pay cut (about 12%). I left all that "expertise" that I built up behind. I did all this with a wife, a one year old daughter (at the time), and a mortgage, and school debt.

That's some Rambo-esque courage! But, you can do it too!

What's the technology that you left behind?


Java. No, wait. More specifically, J2EE enterprise software integration. That means taking some stupid vendor software, like (insert stupid enterprise vendor software here . . . I'm looking at you Documentum), and making it fit into the business no matter what.

What to read


Ok, after you have done Step 1, you can read ALL of the following. Then, send me a 2-page report.

I am too lazy to provide links. So, you just Google it. Also, this list is current as of this date. It is what I would recommend someone to read as they start with Rails. Some of them are coding books. But, others are not.


  • Getting Real

  • The Ten Faces or Innovation

  • Beyond Java

  • From Java to Ruby

  • Extreme Programming

  • Rails Way

  • Ruby Way

  • Web Standards Solutions



I left off the two "Bibles" of Ruby and Rails. I have those. Both are good. But, I do not regularly use them. So, they are left off the list.

There are only two blogs/podcasts to subscribe to that are worth the time:


  • RailsCasts

  • Rails Envy



It's not code, it's passion


Enough said. If you want to discuss, you know where to find me. Out!

Posted at on 8/11/08 by | 0 comments | Filed under: , ,

TextMate: Speed up searching in a project (CMD+Shift+F)

I hate how slow TextMate is when searching in a project. Well, it turns out that it is not really because TextMate's search is slow. It might be. Most likely, the real problem is that, by default, TextMate is searching through ALL your Rails files. ALL, as in logs, vendor/rails, and so forth. This is what is slowing things down.

I don't take any credit for this. This is a tip from Dr. Nic on a TextMate Google Groups thread. But, I will distill it down for you.

Copy this crazy looking piece of regex (at least . . . I think it is regex):

!.*/(\.[^/]*|vendor/rails|doc|rails_root|CVS|log|data_dump|build|_darcs|pkg |_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)? |bundle))$


Fire up TextMate.

Open up Preferences. ("CMD + ," for the cool people.)

Go to Advanced -> Folder References

Picture 1


In the "Folder Pattern" field, delete what is there (you may want to save it somewhere . . . I just gmailed it to myself), and paste in the crazy regex from above.

Done!

Now, TextMate in project search will be much faster!

Posted at on 8/7/08 by | 0 comments | Filed under: ,

Install Memcached on CentOS 5.1

I can use Yum. But, I am going to install from source in order to get the latest builds.

libevent



Memcached requires libevent. So, get and install libevent first.

wget http://monkey.org/~provos/libevent-1.4.6-stable.tar.gz
tar zxpfv libevent*
cd libevent*
./configure
make
sudo make install


memcached



Next, install memcached.

wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar zxpfv memcached*
cd memcached*
./configure
make install


Errors . . . there is always at least one



You may get this error:

error while loading shared libraries: libevent-*: cannot open shared object file: No such file or directory


You need to create a symbolic link. For me, this is the command I needed to run. Yours may differ depending on the release you downloaded.

sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib


Start memcached



memcached -d -m 64 -p 11211


"-d" runs memcached in daemon mode.

"-m" is the amount of memory memcached will use in MB's.

"-p" is the port # for memcached.

Connect to it from Rails 2.1



Rails 2.1 is awesome because of its new caching features. It can support memcached as a cache server. In order to get this to work, add/edit the following line in your config/environment.rb file. Or, you can add/edit your specific environments file, such as config/environments.development.rb file.

config.cache_store = :mem_cache_store, 'IP_ADDRESS_OF_MEMCACHED_SERVER:11211'

Posted at on 8/6/08 by | 3 comments | Filed under: ,

Can an ActiveRecord object destroy itself?

Without getting into real detail, I need this behavior because of a legacy database (Actually, it is not all that "legacy". It is more "enterprise-esque".).

Anyway . . .

Question: Can an ActiveRecord object invoke an instance method, then, while executing that method, destroy itself?

Code example:

@some_object.some_method

Class SomeObject < ActiveRecord::Base
def some_method
...Some really awesome stuff happens here...
self.destroy
end
end

At first, I thought it would work. There are plenty of times where I have invoked a destroy method on an AR object, then use that same AR object later. I do this in controller action methods often.

But, even as I was writing that logic, it did not feel correct. But, Ruby has a tendency to surprise me. So, I gave it a shot.

It turns out that you cannot do this. I am not sure if this is a Ruby or ActiveRecord behavior. If anyone knows, please comment.

To me, it seems like appropriate behavior.

You should not be able to start some set of tasks, one of which causes you to kill yourself, but requires you to finish off the rest of the tasks.

I accomplished the same behavior by creating another object within the instance method, and destroying that object.

Code Example:
@some_object.some_method

Class SomeObject < ActiveRecord::Base
def some_method
...Some really awesome stuff happens here...
SomeObject.find(self).destroy
end
end

Has anyone else come up against this? Am I solving this problem correctly?

Posted at on 8/1/08 by | 5 comments | Filed under: ,

The Presenter Pattern - ActivePresenter for Rails

This is pretty sweet.

Rails strictly adheres to the MVC model . . . which is good. Where Rails falls a little bit short is when a view needs to manipulate multiple models. The out of the box Rails behavior is one model to one controller to one view.

But, in practice, you often have views that manipulate multiple models. Thankfully, because Rails is flexible, you can accomplish this in a number of ways. However, it often leads to inconsistent code structure, and fat controllers, or nearly untestable code.

What we needed was a “pattern”. I had heard about the presenter pattern last year at RailsEdge in Chicago. At the time, it was just a concept. I didn’t really get it.

Looking at this post (ActivePresenter), I get it now. And, its implementation is pure elegance. I can't wait to try it out.

Posted at on 7/30/08 by | 0 comments | Filed under: ,