Journal of a Geek

Archive for the ‘Web Development’ Category

Mission Complete?

leave a comment »

I have finally finished my content management system for the school newspaper…kinda. I was setting up the mongrel server for launch of the website, when my boss comes in to tell me we are giving control of all our server’s back to the school. This means no scripting languages of any kind.

At first I was a bit upset. I had spent a year learning ruby/rails and developing this CMS. My first idea was to simply take the style sheet and apply it to the current site we have. I was dreading this not only because I was going to have to do more CSS work which I hate, but the main reason I had made the CMS, ease of input, would be lost. Thanks to the Rails caching system and a friend (thanks Dane), I came up with a solution that saves the general purpose of the content management system, and gives the website the new look.

For those of you new to Rails, I’ll give a quick explanation of how the caching system works. When Rails creates a page from the view, it is actually generating a hmtl file. So what the caching system does is create a copy of the html file the first time the page is generated. The next time someone request the page the html page that was saved is served instead of the one that needs to be generated. This decreases the load on the server. (Note: Rails can be told to save only specific parts of the page, but that is a bit more detailed than what I used here.)

So if you add the following code to a controller it will cache the pages for you when the Rails application is put into production mode:

caches_page :show, :list

This code tells Rails to cache the show and list pages the first time they are visited. The other part of this is sweeper code which deletes cached pages for you, so that when you change them they get properly updated. I have yet to add that, but will post it once I have completed it.

So my solution was basically consisted of running the website on my local machine, entering the data, then uploading the cached files to the server. I am still kind of sad that I lost my comment, search, and tagging features, but at least I got some use out of it.

Written by Ryan Farnell

September 20, 2006 at 3:18 pm

Posted in Web Development

Ruby on Rails and SQL are great!

leave a comment »

Last night I was working on the newspaper's website, and I wanted to add an anchor to the end of one of the dynamic links Ruby on Rails was making for me. I searched for a few minutes and found out the key was just adding :anchor => "anchor name" to my link code. This is part of the reason I like writing in RoR so much. In any part of the program that is helping you generate a HTML tag, to set an option you just do :attribute => "value" inside your helper tag. This is so much better than memorizing some crazy syntax.

The model queries are great to. You can either use RoR's syntax for really simple queries. For instance, Comments.find(:all, :limit => 5) will find the first five comments in the comment model. If you need a more complex query, it let's you enter SQL statements. If you compare this to something like ASP.NET it's so much easier. In ASP it takes about 8 lines of code to generate that same query.

Speaking of SQL statements, I hadn't worked with straight SQL for about a year now. Last night I was writing a query to find the articles in the newspaper with the most comments. It helped remind me of how simple the SQL syntax is.

Written by Ryan Farnell

June 8, 2006 at 5:10 pm

Posted in Web Development

Things you should know before doing web development…

leave a comment »

Starting from around the 10th grade, I got interested in programming. When I broke my ankle my junior year, I got interested in HTML and web programming. Since then I have been getting more and more involved in web development. I am of course still learning things about web development and do not consider myself a master by any means. But if you are looking to get into web development seriously, these are some things you should really learn about:

1) The basics of computer programming. Even though HTTP is a stateless language, programming for it still follows many of the same rules as a normal state language. You still need to learn what variables, data types, logic statements, loops, data structures, classes, and functions are.

2) Basic HTML. After the programming is done, all web development breaks down to basic HTML. When Ruby on Rails or PHP generates a page from a database, it turns into a basic HTML page. Also, most web programming is done based some what on tags. Knowing HTML will make the whole concept of using tags much easier to grasp.

3) SQL. Nothing lately has influenced my web development skills more than learning SQL. It doesn’t matter if you use mySQL, SQLite, Orcale, SQL Server, or one of the many other database variants. These are all based of basic SQL. Databases begin to open up the whole idea of dynamic web pages. If I can figure out how to store the data in the database easily, I can easily call it back up in any format I want.

4) Learn a web specific language. Once you have a good grasp of programming and database, you can start fooling around with web programming languages. There are a lot of languages and frameworks (helpers for a language designed to make it easier) out there. I would recommend ASP.NET, Ruby on Rails, or PHP.

5) Google. Google is probably the world’s best reference guide for programming, and the best part is that it’s free! You can pretty much type in what you are looking to do, and chances are someone once did it and put it on the web.

6) Stay informed about new web technologies. The main resource I use is TechCrunch and its podcast TalkCrunch.

This is pretty much the path I took learning web programming and development. It may not be the best approach, but it has worked for me. The most important thing is to keep playing with whatever language you are learning. Think of things you want to learn to do and see if you can do them. Also helpful is to look for examples online, and then play around with them to learn what each part of the example does. I hope you find this helpful.

technorati tags:

Written by Ryan Farnell

June 5, 2006 at 3:00 pm

Posted in Web Development