Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of git://github.com/jschementi/ironrubymvc

  • Loading branch information...
commit 0e8072421b26a654bc87becdf8384a64b4bce711 2 parents f21adc6 + 2207788
Ivan Porto Carrero casualjim authored

Showing 2 changed files with 133 additions and 67 deletions. Show diff stats Hide diff stats

  1. +0 67 README
  2. +133 0 README.markdown
67 README
... ... @@ -1,67 +0,0 @@
1   -IronRubyMvc - an extension to ASP.NET MVC to support IronRuby
2   -=============================================================
3   -
4   -IronRubyMvc.Test - Tests Library.
5   -IronRubyMvcWeb - "Hello, World" test website. You need to change the connection string and attach the database or use sql express.
6   -Pictures - "Real" Demo application
7   -
8   -Running IronRubyMvcWeb:
9   -1. Start cassini against the website
10   -
11   -Running Pictures:
12   -1. Start cassini against Pictures
13   -2. ruby Pictures\server\app.rb
14   -
15   -
16   -We now have full support for filters. You can create filters in a number of ways.
17   -
18   -class YourController < Controller
19   -
20   - # before_action, after_action, around_action, before_result, after_result, authorized_action, exception_action all work
21   - before_action :index do |context|
22   - # do some filtering stuff here
23   - end
24   -
25   - around_result :index do |context|
26   - # do some result filtering stuff here
27   - end
28   -
29   - before_action :index, :method_filter
30   -
31   - authorized_action :some_other_action do |context|
32   - # do some authorization checking work here
33   - end
34   -
35   - filter :index, YourFilter
36   - filter :some_other_action, DifferentYourFilter
37   -
38   - # executes for each action
39   - filter YourControllerFilter
40   -
41   - def index
42   - # index action
43   - end
44   -
45   - def some_other_action
46   - # index action
47   - end
48   -
49   - def method_filter
50   - # do some filter stuff here
51   - end
52   -
53   -end
54   -
55   -You can define the following types of filters:
56   -ActionFilter, ResultFilter, AuthorizationFilter, ExceptionFilter
57   -
58   -class YourFilter < ActionFilter
59   -
60   - def on_action_executing(context)
61   - # Do some filter work here
62   - end
63   -
64   - def on_action_executed(context)
65   - # Do some filter work here
66   - end
67   -end
133 README.markdown
Source Rendered
... ... @@ -0,0 +1,133 @@
  1 +IronRubyMvc - an extension to ASP.NET MVC to support IronRuby
  2 +=============================================================
  3 +
  4 +Getting started
  5 +---------------
  6 +
  7 +1. Install ASP.NET MVC (link?)
  8 +2. Create a new ASP.NET MVC project in Visual Studio
  9 +3. Add a reference to System.Web.Mvc.IronRuby.dll
  10 +3. Open Global.asax.cs and ...
  11 +
  12 + // add this to your usings
  13 + using System.Web.Mvc;
  14 +
  15 + // make the subclass of "MvcApplication" be "RubyMvcApplication"
  16 + namespace MyIronRubyMvcApp {
  17 + public class MvcApplication : RubyMvcApplication {
  18 +
  19 + }
  20 + }
  21 +
  22 +4. Create Routes.rb and define a default route:
  23 +
  24 + $routes.ignore_route "{resource}.axd/{*pathInfo}"
  25 + $routes.map_route "default", "{controller}/{action}/{id}", :controller => 'Home', :action => 'index', :id => ''
  26 +
  27 +Controllers
  28 +-----------
  29 +
  30 +Ruby Controllers live in the same directory as normal MVC controllers: the "Controllers" directory.
  31 +
  32 + # Controllers\HomeController.rb
  33 + class HomeController < Controller
  34 + def index
  35 + "Hello, World"
  36 + end
  37 + end
  38 +
  39 +Run the application from Visual Studio, and it will display "Hello, World"
  40 +
  41 +Filters
  42 +-------
  43 +
  44 +You can create filters in a number of ways.
  45 +
  46 + class YourController < Controller
  47 +
  48 + # before_action, after_action, around_action, before_result, after_result, authorized_action, exception_action all work
  49 + before_action :index do |context|
  50 + # do some filtering stuff here
  51 + end
  52 +
  53 + around_result :index do |context|
  54 + # do some result filtering stuff here
  55 + end
  56 +
  57 + before_action :index, :method_filter
  58 +
  59 + authorized_action :some_other_action do |context|
  60 + # do some authorization checking work here
  61 + end
  62 +
  63 + filter :index, YourFilter
  64 + filter :some_other_action, DifferentYourFilter
  65 +
  66 + # executes for each action
  67 + filter YourControllerFilter
  68 +
  69 + def index
  70 + # index action
  71 + end
  72 +
  73 + def some_other_action
  74 + # index action
  75 + end
  76 +
  77 + def method_filter
  78 + # do some filter stuff here
  79 + end
  80 +
  81 + end
  82 +
  83 +You can define the following types of filters:
  84 +ActionFilter, ResultFilter, AuthorizationFilter, ExceptionFilter
  85 +
  86 + class YourFilter < ActionFilter
  87 +
  88 + def on_action_executing(context)
  89 + # Do some filter work here
  90 + end
  91 +
  92 + def on_action_executed(context)
  93 + # Do some filter work here
  94 + end
  95 + end
  96 +
  97 +Views
  98 +-----
  99 +
  100 +Ruby views exist in the Views directory, in a sub-folder with the same name as the Controller the View
  101 +is intended to be used in. To use ERb views, the file should have the ".html.erb" extension. Shared views,
  102 +such as layouts, are in the "Views/Shared" directory.
  103 +
  104 +For example, an "index" view for the HomeController would be in
  105 +Views/Home/index.html.erb.
  106 +
  107 + # Controllers/HomeController
  108 + class HomeController < Controller
  109 + def index
  110 + data = "Hello, World"
  111 + view 'index', 'layout', data
  112 + end
  113 + end
  114 +
  115 + <!-- Views/Home/index.html.erb -->
  116 + MVC says: <%= model %>
  117 +
  118 + <!-- Views/Shared/layout.html.erb -->
  119 + <h1><% yield %></h1>
  120 +
  121 +Samples
  122 +-------
  123 +
  124 +IronRubyMvc.Test - Tests Library.
  125 +IronRubyMvcWeb - "Hello, World" test website. You need to change the connection string and attach the database or use sql express.
  126 +Pictures - "Real" Demo application
  127 +
  128 +Running IronRubyMvcWeb:
  129 +1. Start cassini against the website
  130 +
  131 +Running Pictures:
  132 +1. Start cassini against Pictures
  133 +2. ruby Pictures\server\app.rb

0 comments on commit 0e80724

Please sign in to comment.
Something went wrong with that request. Please try again.