Hi Ivan Porto carrero,
Great work on the MVC IronRuby sample!
I am curious to know how it works! I created an ASP.NET MVC application.
I created the controller and view but how will the views get called.
Here is my controller:
require ‘application_controller’
class HomeController < ApplicationController
def index
@message = “Welcome from IronRuby!”
view(‘Index’)
end
def about
view(‘Index’)
end
end
And here is the view:
<%= html.encode(view_data.message) %>
To learn more about ASP.NET MVC visit http://asp.net/mvc.
Thanks!
For some reason it is not running for me out of the box. When I run the
application the following exception is thrown:
Could not load file or assembly ‘System.Data.SQLite’ or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
Even though the reference to System.Data.SQLite is already made!
You have a 32-bit machine right?
You need to download the 32-bit version of the System.Data.SQLite.dll
and
replace that one… I’ve got one here if you want it, email me off-list
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Asp.net MVC has the ability to add view engines
Each view engine defines a bunch of search patterns, and you can
configure
the location of the views but the convention is views so I’d stick with
that

When you request the view “index” the controller will ask the view
engines
collection if it can find a view with that name in a location
/views/controllername/
The first view that matches the file name like index.html.erb or
index.aspx
also selects the view engine. From there on the view engine reads the
file
and executes it, after setting a bunch of variables that can be used in
the
view script like the view data dictionary.
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
rename them to .html.erb that should work.
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Is there any special place where you register the ViewEngine. I have
files with extensions .rhtml but they are not being picked up by the MVC
application.
I tried it!
It is throwing a 404 error:
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure
that it is spelled correctly.
Requested URL: /account
Here is the controller:
class AccountController < Controller
def index
@message = “Welcome from IronRuby!”
return view
end
def about
return view
end
end
And here is the View:
Hello from IronRuby!
Thanks,
Do I also need mvc_application even thought I am not using the
LightSpeed data access layer?
Does the sample work on your machine if you use the correct sqlite
assembly?
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
If I load the Default.aspx page I get the following error:
The incoming request does not match any route.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The incoming request does
not match any route.
Source Error:
Line 16:
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
Line 17: IHttpHandler httpHandler = new MvcHttpHandler();
Line 18: httpHandler.ProcessRequest(HttpContext.Current);
Line 19: HttpContext.Current.RewritePath(originalPath,
false);
Line 20: }
Source File:
C:\Projects\IronRubyMVCWebApps\IronRubyMVCWebApps\IronRubyMVCWebApps\Default.aspx.cs
Line: 18
I have all the routes in the Routes.rb file:
require ‘mvc_application’
#default routes
$routes.ignore_route("{resource}.axd/{*pathInfo}");
$routes.map_route(“default”, “{controller}/{action}/{id}”, {:controller
=> ‘Home’, :action => ‘index’, :id => ‘’})
I have not tried it with the SqlLite assembly.
I am simply trying to say “/home” and it should trigger the
HomeController.
I am following this example:
Here is the latest error:
The incoming request does not match any route.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The incoming request does
not match any route.
Source Error:
Line 16:
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
Line 17: IHttpHandler httpHandler = new MvcHttpHandler();
Line 18: httpHandler.ProcessRequest(HttpContext.Current);
Line 19: HttpContext.Current.RewritePath(originalPath,
false);
Line 20: }
Source File:
C:\Projects\IronRubyMVCWebApps\IronRubyMVCWebApps\IronRubyMVCWebApps\Default.aspx.cs
Line: 18
Is there any link between the IronRubyMvcLibrary?
Do I need that library?
How will the application know to load the routes from routes.rb file?
Where can I download the 32 bit version?
Ivan Porto carrero wrote:
You have a 32-bit machine right?
You need to download the 32-bit version of the System.Data.SQLite.dll
and
replace that one… I’ve got one here if you want it, email me off-list
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
Sqlite lib:
You need to have a reference to the ironrubymvc library and compile the
asp.net mvc project once from then on things should start to work.
Getting started
- Install ASP.NET MVC (link?)
- Create a new ASP.NET MVC project in Visual Studio
- Add a reference to System.Web.Mvc.IronRuby.dll
-
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 => ‘’
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
GSM: +32.486.787.582
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
The ironruby mvc library being System.Web.Mvc.IronRuby.dll
and the routes got borked
$routes.ignore_route “{resource}.axd/{*pathInfo}”
$routes.map_route “default”, “{controller}/{action}/{id}”, :controller
=>
‘Home’, :action => ‘index’, :id => ‘’"
I suggest
you take jimmy’s repository of ironrubymvc. I will sometimes break
existing functionality
You should also be able to re-use existing filters defined in C# etc.
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
On Tue, Jun 23, 2009 at 9:33 PM, Ivan Porto C.
[email protected]wrote:
- Install ASP.NET MVC (link?)
$routes.map_route “default”, “{controller}/{action}/{id}”, :controller =>
‘Home’, :action => ‘index’, :id => ‘’"
I copied your code to a new project and still it is giving me issues. It
is not picking up the Routes.rb file.
Is there anything interesting in ApplicationController since I am not
using ApplicationController.
In your download you never subclass from RubyMvcApplication. I have
tried to subclass from RubyMvcApplication but it is giving me the same
issue:
The incoming request does not match any route.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The incoming request does
not match any route.
Source Error:
Line 16:
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
Line 17: IHttpHandler httpHandler = new MvcHttpHandler();
Line 18: httpHandler.ProcessRequest(HttpContext.Current);
Line 19: HttpContext.Current.RewritePath(originalPath,
false);
Line 20: }
Source File:
C:\Projects\IronRubyMVCWebApps\IronRubyMVCWebApps\IronRubyMVCWebApps\Default.aspx.cs
Line: 18
I am not using SqlLite anymore!!
I just want to trigger the action and display the view.
I am running ASP.NET 3.5 using ASP.NET build in server.
Here is everything:
Routes.rb:
#default routes
$routes.ignore_route(“{resource}.axd/{*pathInfo}”);
$routes.map_route(“default”, “{controller}/{action}/{id}”, {:controller
=> ‘Home’, :action => ‘index’, :id => ‘’})
home_controller.rb:
class HomeController < Controller
def index
@message = “Welcome to ASP.NET MVC!”
view
end
def about
view
end
end
Views/Home/index.html.erb
<%= html.encode(view_data.message) %>
To learn more about ASP.NET MVC visit http://asp.net/mvc.
Global.asax:
public class MvcApplication : RubyMvcApplication
{
}