views:

129

answers:

4

I have recently designed a web application that I would like to write in Ruby. Coming from a ASP background I designed it with method and fields and linked them together (in my diagram and UML) like I would do it in C#.

However, now that I've moved from a single app to MVC I have no idea where my code goes or how the pieces are linked.

For example, my application basically collects information from various sources for users, and when they log in the information is presented to them with "new" information (information collected since last login) is tagged specially in the interface.

In C# I would have a main loop that waits lets say 5 minutes and does the collection, then when a client tries to connect it would spawn a new thread that generates the page with the new information. Now that I'm moving to Ruby I'm not sure how to achieve the same result.

I understand that the controller connects the model to the view and I thus assume this is where my code goes yet I've haven't seen a tutorial that talks about doing what I've mentioned. If someone could point me to one or tell me precisely what I need to do to turn my pseudocode into production code I'd be extremely grateful and probably will still have hair :D

EDIT: Somehow I forgot to mention that I'll be using the Rails framework. I don't really like Ruby but RoR is so nice together that I think I can put up with it.

Thanks.

+3  A: 

I realize you want to move to Ruby; but you may want to give ASP.NET MVC a shot. It's the MVC framework on the ASP.NET platform.

Coming from ASP, you're going to have to do a lot of conversion to change your code to become more modular. Much more than any one post on Stack Overflow will do justice.

MVC is made up into 'tiers':

Model - Your Data
View - What the user Sees
Controller - Handles requests and communicates with the View and Model.

Pick up a book on ASP.NET MVC 1.0, and do some research on the MVC pattern. It's worth it.

George Stocker
Thanks for the reply george however I should mention we have to move to a open stable web frame work. My whole team is C#/java coders but this project has to run on linux and be scalable (so java and C# are out)
edude05
"Scalable"? Are you sure Ruby on Rails is more Scalable than the ASP.NET framework? Keep in mind that Stack Overflow runs on ASP.NET MVC. It's very stable and very scalable. As far as running on Linux (Why?) you can run ASP.NET MVC on Mono (the Linux port of the .NET Framework). So there's no reason not to stick with ASP.NET MVC and C#.
George Stocker
Not that I'm any huge fan of Java, but why wouldn't Java be "scalable"? And it runs on Linux...
Blake Pettersson
Well, the specific issue is that this is an application is going to be a free service that I'm designing to handle up to hundreds of thousands of users. Since it will be free there is no point of buying windows server licenses for the cluster it will run on. Also, mono might work but we've had trouble in the past getting our working C# apps running on it, though it worth another look I guess.
edude05
+3  A: 

The part of your application that is retrieving the data at certain interval shouldn't be, strictly speaking, part of the web application. In Unix world (including Rails), it would be implemented either as a daemon process, or a cron job. On Windows, I presume that Windows service is the right tool.

Regarding C# -> Ruby transition, if that's purely for Rails, I'd listen to the George's advice and give ASP.NET MVC a shot, as it resembles Rails logic pretty closely (some would call it a ripoff, I guess ;)). However, learning a new language, especially so different than C# as Ruby is, is always a good idea and a way to improve yourself as a developer.

Mladen Jablanović
A: 

Check out Rails for .NET Developers. I've heard good things about this book and it sounds like it's just what you're looking for.

jamesaharvey
+1  A: 

Whatever Ruby web framework you plan to use (Rails, merb, Sinatra), it sounds like the portion that collects this data would typically be handled by a background task. Your models would be representations of this data, and the rest of your web app would be pretty standard.

There are some good Railscast episodes on performing tasks in the background:

There are other options for performing tasks in the background (such as using a message queue and the ActiveMessaging plugin) but these screen casts will at least give you a feel for how background jobs are generally approached in Rails.

If you perform these tasks on a regular schedule, there are tools for that as well.

I hope this is of some help.

Ian