Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC for Ruby on Rails developers?

Long time lurker, first time poster. I'm a self-taught hacker that learned Ruby on Rails to start. At work I've been allowed to work on a web app--the only catch is I have to use ASP.NET. This technology choice is mandated, as much as I'd prefer to use Rails.

There's dozens of "Rails for .NET/PHP/Java Developers" books and blog posts but I haven't found any going the opposite direction, from Rails to .NET.

Could someone please give me an overview of how a typical Rails app would translate over to ASP.NET MVC? I'll research the details of the IDE, C#/VBscript, etc. But what are the possible equivalents to:

  • Generators
  • Gems/Plugins
  • Databases
  • Migrations
  • Routes
  • Models (ORMs)
  • Controllers (InheritedResources)
  • Views (layouts, templates, partials)
  • Rails Console
  • Test Units/Specs
  • etc. anything else I'm forgetting

I assume a lot of the Rails niceties I take for granted like route-based helper methods, and simple macro association declarations will not be possible. :(

Thank you so much!

like image 417
ASP.NET MVC for Rails devs Avatar asked Feb 17 '10 19:02

ASP.NET MVC for Rails devs


3 Answers

I think what you'll find in the .Net world is that you have a lot of choices to make. Rails is nice because it provides all of that stuff in one place, but developing for .Net you'll have to piece together a solution of your own.

  • Generators - There are various code generation facilities, but each one is for a different piece. Eg, you can get MyGeneration that will generate code based on a database.
  • Gems/Plugins - No uniting system for this; Components can be found on the web and you would download either the source or the .dll, then you would add a reference in your project to the assembly (.dll).
  • Databases - you can connect to pretty much anything; You'll probably find the most guidance for an MS SQL Server.
  • Migrations - I don't know of a direct method for this in the .net world; I usually write SQL code in SQL and run scripts on the server manually as part of deployment.
  • Routes - ASP.Net MVC includes routes, look in the global.asax.cs file that gets generated when you create a project for example.
  • Models (ORMs) - ORMs for .Net are all over the place. Included as part of .Net are things like Linq-to-sql and the Entity Framework. Outside of MS you can find many, but I'd probably recommend NHibernate.
  • Controllers - Built in to .Net MVC; You get to write the code.
  • Views - Built in to .Net MVC; Once again you get to write them. MasterPages allow you to get the same general layout on all your pages(including common header/footer, etc), Web Controls (.ascx files) allow you to do a partial view.
  • Rails Console - I don't know exactly what this provides (I'm a .net developer interested in learning Rails, but haven't spent much time yet); Visual Studio lets you debug applications, step through code, etc. I don't think there are any consoles available to test code outside of just writing the code, compiling, and running it.
  • Test Units/Specs - There are a few test frameworks for .Net (MS has a framework included, NUnit is one alternative). For specs and such, probably google around for Behavior Driven Design and see what exists.
like image 110
Chris Shaffer Avatar answered Nov 20 '22 13:11

Chris Shaffer


There are a couple of .NET ports of RoR migrations. I have used migratordotnet and FluentMigrator. Both work as expected but I prefer FluentMigrator. It is more full-featured (e.g. can create indexes) and I like the fluent style.

like image 32
Daniel Lee Avatar answered Nov 20 '22 13:11

Daniel Lee


LINQPad is your equivalent to Rails Console.. see here: https://stackoverflow.com/a/9403457/1029644

like image 2
Lloyd Avatar answered Nov 20 '22 11:11

Lloyd