Posts [ 20 ]

Topic: Is Ruby/Rails for me?

Hello, all.

I'm a middle school teacher with a strong interest in technology and computers. I have a few ideas for web projects that I would like to try to develop over the summer.

I am curious to get your opinion as to whether Ruby/Rails is a good environment for me to persue, or if there is a different programming environment that would be more appropriate to my (lack of) programming experience or my project description.

My Project Idea:My primary hope is to create a database-driven book review website that would be accessed by middle school students. Ideally, I'd like to interface with Amazon's book database, and make it easy for students to discover books that "kids just like them" seemed to like.

My Programming Experience:* I took one semester of Pascal 20 years ago...but loved it.* I have extensive Access experience, so I know a good deal about basic database design and querying (though I never wrote SQL by hand -- only using Access query graphical interface).

My Ruby Reading:* I've read Chris Pine's "Learn to Program", and was able to handle most of the basic programming challenges (I'm particularly proud of my "99 Bottles of Beer" program!).* I tried working along with David A. Black's "Ruby for Rails" r4rmusic example. I quickly got discouraged though, as things didn't seem to work as written (though it's probably my fault) and it seemed to be a much steeper learning curve up from Chris Pine's book. I haven't put a ton of time into this one yet (I'll have to wait for the school year to end before I can) but it did spook me a bit!

I'm a terrific "book buyer" on Amazon, so I already have a small library of Ruby books (Pick Axe, Cookbook, Recipes, Quiz, etc.), but I can't seem to find a good bridge between Chris Pine's book and any of the others.

Beyond Ruby/Rails, I am quickly realizing that there is much more to master to make this work, including MySQL, CSS, Amazon EC2, etc.

Is this too much for a capable newbie to take on? If I do, is Ruby/Rails the best choice for my experience and project requirements?Is there another environment that might be faster to learn and appropriate to the job?

Re: Is Ruby/Rails for me?

Rails would be a great fit for your project. So would Django or even Code Igniter. It really depends on your preference of programming language. This requires you to really take a look at how different languages address different problems.

Before you go "code-shopping" though, I would recommend you get your HTML/CSS skills up to par. Some javascript wouldn't hurt either.

I would recommend reading CSS Mastery, best book I have read on the subject.

Re: Is Ruby/Rails for me?

Hi pimpmaster,

Thanks for the feedback.

It's funny that you mentioned CSS Mastery...it's another one of the books that I purchased during one of my Amazon binges. Unfortunately, it was another example of a book that was just a bit over my head. I think I need a "CSS for Dummies" book first, before I can handle CSS Mastery.

For some reason (rightly or wrongly) I'm less concerned right now about CSS and HTML -- I guess I figure I can make the site look "pretty" after I have the basic plumbing working well.

After reading (or browsing) many of the Ruby/Rails books, I get the impression that most Ruby programmers came to Ruby after significant experience with other languages or frameworks. My concern is that Ruby/Rails may be too complex an environment to learn from "scratch" without first having mastered some other language or framework. Or perhaps, that Ruby/Rails is still too new to have books written that fit the "advanced beginner" niche between Chris Pine's terrific beginner book and virtually all the other books.

I'd love to hear from anyone who has been successful with Ruby/Rails as their first programming language experience: how did you go from complete beginner to a productive coder?

Re: Is Ruby/Rails for me?

* I've read Chris Pine's "Learn to Program", and was able to handle most of the basic programming challenges (I'm particularly proud of my "99 Bottles of Beer" program!).

Glad to see you've already got this, I was going to suggest it otherwise.

misterlawrence wrote:

* I tried working along with David A. Black's "Ruby for Rails" r4rmusic example.

I don't consider Ruby for Rails the best introduction to Rails. I think it's a good book to read after you've played around with Rails for a bit but want to get a deeper understanding of how everything works.

misterlawrence wrote:

I'm a terrific "book buyer" on Amazon, so I already have a small library of Ruby books (Pick Axe, Cookbook, Recipes, Quiz, etc.), but I can't seem to find a good bridge between Chris Pine's book and any of the others.

Do you have the 2nd edition of Agile Web Development with Rails? That's probably the best one, but the depot app tutorial does a few things I don't like (administration section, storing cart in session, etc.). Build Your Own Rails App is also very good. It's not quite as complete as AWDwR, but I like the tutorial better.

Even with these books it takes a while to get off the ground to the point you can build apps on your own. You just have to follow the tutorials by the letter until then.

misterlawrence wrote:

Beyond Ruby/Rails, I am quickly realizing that there is much more to master to make this work, including MySQL, CSS, Amazon EC2, etc.

So true. Rails brings together a lot of different technologies. If you're having trouble with something specific I highly recommend taking some time to learn it on its own. Sounds like you got some basic Ruby skills down, but you might want to focus on HTML & CSS. Build a few static pages.

MySQL probably won't be too much of a problem as Rails does a good job of providing its own find methods. You'll want to learn it eventually, but I wouldn't call it required for beginners.

misterlawrence wrote:

Is this too much for a capable newbie to take on?

Depends how much you're willing to put into it. For most people Ruby is the biggest learning curve in learning Rails and it sounds like you've got a good start on that. Just realize that it may be a month or two before you get a good grasp on Rails.

misterlawrence wrote:

If I do, is Ruby/Rails the best choice for my experience and project requirements?

Considering you already know some Ruby, definitely. Pretty much anything else you go with you'll have the same learning curves (HTML, CSS, SQL, etc.). Deployment might be a little harder than some other languages (PHP) but I don't think it's too bad.

misterlawrence wrote:

Is there another environment that might be faster to learn and appropriate to the job?

There may be some pre-built solution out there which allows you to organize amazon books. It might not exactly fit your requirements but it may be good enough.

That said, it sounds like you enjoy programming and want to get into web development. In that case I don't think you will find something better than Rails.

Re: Is Ruby/Rails for me?

Hi ryanb,

Thanks for your thoughtful reply!

A quick aside: how do you "quote" somebody in this forum? I don't see any controls for it on the reply screen, but it can clearly handle it nicely!

I do have the Agile Web Development book (2nd edition) and I will definitely give it a go next. The reviews of Build Your Own Ruby on Rails Web Applications on Amazon make it look really great, but I will try to resist the urge of buying yet another Ruby book until I've given Agile a good read through!

I will do the HTML/CSS learning this summer, but I really want to first see if I can get the basic plumbing down on the site that I want. If I can't manage that, then I won't really need the other knowledge as much.

On the Amazon side of things, I have found that there are several GEMs that access the Amazon EC2 stuff -- I've played around with one, and can't get it to work, but that's just par for the course for me right now! I think I'll put the Amazon stuff to the side for now, and just see if I can manage the basic database stuff in Ruby/Rails first.

Re: Is Ruby/Rails for me?

I should probably start another thread for this question, but it still seems relevant to this topic, so I'll just throw the question out there:

As I mentioned before, I have some decent Access database experience, but I am used to creating my tables, joins, and queries through Access screens.

In the Ruby/Rails books I have been playing with, all the building of MySQL tables seems to be done through text files. This is really foreign to me, and seems like yet another learning curve I will have to climb.

Is it necessary to build the MySQL tables by text file, or could I use Access (or a similar tool) to build my database?

Re: Is Ruby/Rails for me?

I think I'll put the Amazon stuff to the side for now, and just see if I can manage the basic database stuff in Ruby/Rails first.

That's a good idea. Always best to simplify things as much as possible when learning.

misterlawrence wrote:

In the Ruby/Rails books I have been playing with, all the building of MySQL tables seems to be done through text files. This is really foreign to me, and seems like yet another learning curve I will have to climb.

Migrations in Rails are not too hard once you get the hang of it. For the most part all you're doing is defining the name of the table, the names of the columns in the table, and what type each column is (string, integer, etc.).

Is it necessary to build the MySQL tables by text file, or could I use Access (or a similar tool) to build my database?

I'm not sure about Access, but you can use any tool which connects to a MySQL database. There are many apps out there, but I'm not sure of the best one as I don't have experience with them.

That said, if you're going through a tutorial then I recommend following it exactly, so if they use migrations, use that. This will lessen the chance of there being problems/differences further along in the tutorial. On your own proejcts though, feel free to use what suits you.

Re: Is Ruby/Rails for me?

Does this end up recreating the tables each time they are run (and deleting all the data that was previously entered)?

Nope, this is one reason to use migrations. Every time you need to make a change to the database you create a new migration script. This way you just run that script and it doesn't recreate everything. Rails keeps track of this automatically, so it only runs the migrations necessary to get the database up to date.

This becomes extremely helpful when you have multiple databases (one on your production server and one for your local development). This way the migration script just gets run on both computers to get the database up to date and in sync.

Re: Is Ruby/Rails for me?

I am guessing that I haven't been exposed to Migrations yet in my reading. They were certainly not covered in Chris Pine's book, and I probably didn't get far enough into "Ruby for Rails" to even see it! (At least at the start of Ruby for Rails, the author has you create a MySQL table using a script, and if I recall properly, mentioned that there were better ways to handle it but that it would be saved for later in the book).

I think I will just switch over to the "Agile" book for a bit and see if that helps. If not, perhaps Build Your Own Ruby on Rails Web Applications will be helpful.

Re: Is Ruby/Rails for me?

That makes a lot of sense. I just need to get to the point where I can even being to try to implement my ideas -- I don't have quite enough knowledge (yet) to begin.

I did find that coding the "challenges" in Chris Pine's book was a great starting point, and definitely a good learning experience for me.

I think my next step is to dive back into the books at least enough so that I can "try" to start my project -- then, when I hit a roadblock, post an S.O.S. up here!

I am really impressed with the support that the people on this forum are willing to give. Everyone has been so generous with their advice and time. Perhaps someday I'll learn enough to give back as well...

Re: Is Ruby/Rails for me?

If you want to get another book (LOL) you might want to look into Beginning Ruby. It just covers Ruby, not Rails, but it goes beyond Learning to Program. I haven't read it, but from his description of it in Peter Cooper's Interview it sounds like a great next step if you're having trouble grasping Rails.

Re: Is Ruby/Rails for me?

misterlawrence wrote:

Is it necessary to build the MySQL tables by text file, or could I use Access (or a similar tool) to build my database?

Migrations were the big selling point for me with RoR. I come from an ASP world and with RoR its so refreshing to have the option to use migrations. They are easy enough to learn and once you make a few mistakes and see the results (or lack thereof) they will become totally clear.

They make it easy to add or remove database columns and tables in the future without having to vastly alter your code and cross your fingers hoping a new change or addition actually works with the rest of the application.

If I were you I would take the little extra time to really understand them. They will save you a lot of effort down the road.

Re: Is Ruby/Rails for me?

Bink wrote:

misterlawrence wrote:

Is it necessary to build the MySQL tables by text file, or could I use Access (or a similar tool) to build my database?

Migrations were the big selling point for me with RoR. I come from an ASP world and with RoR its so refreshing to have the option to use migrations. They are easy enough to learn and once you make a few mistakes and see the results (or lack thereof) they will become totally clear.

They make it easy to add or remove database columns and tables in the future without having to vastly alter your code and cross your fingers hoping a new change or addition actually works with the rest of the application.

If I were you I would take the little extra time to really understand them. They will save you a lot of effort down the road.

Migrations confuse the heck outta me too. I think someone needs to update the Cookbook tutorial to use migrations.

Re: Is Ruby/Rails for me?

Ok Ill try to explain migrations in plain english. I dont have access to my personal machine right now so some of the filenames may not be 100% accurate but I'll try.

You have your migration file. At the beginning of the migration file name is a number (001, 002, 003 etc.). When you run your migrations rails looks at the migrations that have already run and automatically chooses the next number based on the ones in the file names.

Within each migration there is a "do" and "undo" section. You're basically telling rails what to add to the database - but you are also telling rails how to undo the exact same changes.

So if you have run 002xxxxxxx previously it will know that and look for 003xxxxxx.rb. If it exists it will run it. If you have run migration 006xxxxx but need to run 007, 008 & 009 once you run the next migration rails will run the 007 first, then the 008, then the 009 migration. If you have run migration 009 and you want to revert back to migration 006 rails will call the "undo" portion of 009, then the undo portion or 008, then the undo portion of 007.

Every migration file should have an "undo" section that directly reflects the changes made by the "do" section. This way if you make a mistake you will be able to "roll back" the changes in the database. Believe me - its usually a lot easier to do it this way than to open the database and do it there.

But how do you undo a change?OK - say you have just run the migration 003xxxxxxxx but you made a mistake and you want to roll back the DB. To active the "undo" section in 003 you need to tell rails that you want to ge back to the 002 version. When you type in "rake:DB migrate Version=2" (I think that is the correct code) you are telling rails to step back to the v2 migration (or 002xxxxxx). Rails will know that you have run 003xxxxx and will invoke the undo section of that file bringing you back to where you were before you ran the 003 migration (i.e. the database will look like it was after the 002 migration)

Ok - so it might be a bit of a rambling explanation but hopefully it'll give you a clearer picture. I'll update it later with better filenames and references.