Ruby on Rails and ASP.NET MVC are compared for building a conference registration application. Both frameworks support generating models from a database, including validation rules. Both also provide automatic routing and controllers to display data. The main differences are that Rails uses Ruby code and conventions while ASP.NET MVC uses C# and the MVC pattern. Views in Rails use Haml or ERB templates whereas ASP.NET MVC uses Razor syntax.
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ruby on Rails vs ASP.NET MVC
1. Ruby on RailsvsASP.NET MVC SandroPaganottiSoftware Architect, Wave Factory http://sandropaganotti.com/ Twitter: @sandropaganotti Simone ChiarettaWeb Architect, Council of the EU http://codeclimber.net.nz Twitter: @simonech Milano, 19 Febbraio 2011
7. Project Setup rails new join_the_conf -d mysql cd join_the_conf mate config/database.yml rakedb:create rails server [File>New Project>ASP.NET MVC 3 Application]
9. Create Model rails generateresourceConference name:string description:text start:date end:date location:string capacity:integer -a index public class Conference { public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public DateTime Start { get; set; } public DateTime End { get; set; } public string Location { get; set; } public int Capacity { get; set; } }
11. Validation class Attendee < ActiveRecord::Base belongs_to :conference validates_presence_of :conference_id, :name, :email validates_uniqueness_of :email, :scope => :conference_id end public class Attendee { public int Id { get; set; } public intConferenceId { get; set; } [Required] public string Name { get; set; } [Required] public string Email { get; set; } virtual public Conference Conference { get; set; } }
12. Routing resources "conferences", :only => [:index] do resources "attendees", :only => [:index, :create] End rake routes public class ConferencesController : Controller public ViewResult Index() public class AttendeesController : Controller public ViewResult Index() public ActionResultCreate(Attendeeattendee)
13. Controller class ConferencesController ... def index @conferences = Conference.all( :order=>'start DESC') end end public class AttendeesController : Controller { privateJTCContextcontext = new JTCContext(); public ViewResult Index() { return View(context.Attendees.ToList()); } }