github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

casualjim / ironrubymvc forked from jschementi/ironrubymvc

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 19
    • 4
  • Source
  • Commits
  • Network (4)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • master ✓
    • mono
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

IronRuby ASP.NET MVC otherwise known as ASP.NET MVC rubification — Read more

  cancel

http://codeplex.com/aspnet

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Makes call to require so it can be patched 
casualjim (author)
Wed Oct 14 00:06:37 -0700 2009
commit  bc80a3057f48c3064ddb99f5700d8279f0455189
tree    cc4c3b104b32abd9c7fbaaad82327974dd22f947
parent  65d978f215289d44fd1573da57d92502d6a6ac31
ironrubymvc /
name age
history
message
file .gitignore Tue Oct 13 07:16:08 -0700 2009 Fixed IronRubyMvcWeb project to copy IronRuby.d... [iwache]
directory IronMvcSpecs/ Sun Jun 14 11:30:51 -0700 2009 Adds some specs. Fixes filters from parent classes [casualjim]
directory IronRubyMvc.Tests/ Tue Oct 13 12:20:19 -0700 2009 Test added for: when_a_ruby_controller_was_reso... [iwache]
file IronRubyMvc.sln Mon Oct 12 20:15:43 -0700 2009 xUnit.net to 1.5 updated, xunitbddextensions to... [iwache]
directory IronRubyMvc/ Wed Oct 14 00:06:37 -0700 2009 Makes call to require so it can be patched [casualjim]
file IronRubyMvcKey.public Sat Feb 14 05:45:15 -0800 2009 Added some more tests and moved ruby engine to ... [casualjim]
file IronRubyMvcKey.snk Sat Feb 14 05:45:15 -0800 2009 Added some more tests and moved ruby engine to ... [casualjim]
directory IronRubyMvcWeb/ Tue Oct 13 07:16:08 -0700 2009 Fixed IronRubyMvcWeb project to copy IronRuby.d... [iwache]
file README.markdown Tue May 19 13:20:46 -0700 2009 Added a few specs for RubyEngine [casualjim]
directory VS Templates/ Thu Mar 26 13:57:01 -0700 2009 Fixed a bug with the validation helper. Added a... [casualjim]
directory dependencies/ Tue Oct 13 07:48:21 -0700 2009 Merge branch 'master' of git://github.com/casua... [iwache]
README.markdown

IronRubyMvc - an extension to ASP.NET MVC to support IronRuby

Getting started

  1. Install ASP.NET MVC (link?)
  2. Create a new ASP.NET MVC project in Visual Studio
  3. Add a reference to System.Web.Mvc.IronRuby.dll
  4. Open Global.asax.cs and ...

    // add this to your usings using System.Web.Mvc;

    // make the subclass of "MvcApplication" be "RubyMvcApplication" namespace MyIronRubyMvcApp {

    public class MvcApplication : RubyMvcApplication {
    
    }
    
    }
  5. Create Routes.rb and define a default route:

    $routes.ignore_route "{resource}.axd/{*pathInfo}" $routes.map_route "default", "{controller}/{action}/{id}", :controller => 'Home', :action => 'index', :id => ''

Controllers

Ruby Controllers live in the same directory as normal MVC controllers: the "Controllers" directory.

# Controllers\HomeController.rb class HomeController < Controller

def index
  "Hello, World"
end

end

Run the application from Visual Studio, and it will display "Hello, World"

Filters

You can create filters in a number of ways.

class YourController < Controller

 # before_action, after_action, around_action, before_result, after_result, authorized_action, exception_action all work
 before_action :index do |context|
   # do some filtering stuff here
 end

 around_result :index do |context|
   # do some result filtering stuff here
 end

 before_action :index, :method_filter

 authorized_action :some_other_action do |context|
   # do some authorization checking work here
 end

 filter :index, YourFilter
 filter :some_other_action, DifferentYourFilter

 # executes for each action
 filter YourControllerFilter 

 def index
   # index action
 end

 def some_other_action
   # index action
 end

 def method_filter
  # do some filter stuff here
 end

end

You can define the following types of filters: ActionFilter, ResultFilter, AuthorizationFilter, ExceptionFilter

class YourFilter < ActionFilter

def on_action_executing(context)
  # Do some filter work here
end

def on_action_executed(context)
  # Do some filter work here
end

end

Views

Ruby views exist in the Views directory, in a sub-folder with the same name as the Controller the View is intended to be used in. To use ERb views, the file should have the ".html.erb" extension. Shared views, such as layouts, are in the "Views/Shared" directory.

For example, an "index" view for the HomeController would be in Views/Home/index.html.erb.

# Controllers/HomeController class HomeController < Controller

def index
  data = "Hello, World"
  view 'index', 'layout', data
end

end

<!-- Views/Home/index.html.erb --> MVC says: <%= model %>

<!-- Views/Shared/layout.html.erb -->

<% yield %>

Samples

IronRubyMvc.Test - Tests Library. IronRubyMvcWeb - "Hello, World" test website. You need to change the connection string and attach the database or use sql express. Pictures - "Real" Demo application

Running IronRubyMvcWeb: 1. Start cassini against the website

Running Pictures: 1. Start cassini against Pictures 2. ruby Pictures\server\app.rb

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server