# MVC architecture

**URL:** <https://www.ruby-forum.com/t/mvc-architecture/64167>\
**Category:** Rails\
**Created:** [June 22, 2006, 7:19pm UTC](https://www.ruby-forum.com/t/mvc-architecture/64167 "2006-06-22T19:19:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerome](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@jerome](https://www.ruby-forum.com/u/jerome)\
**Post date:** [June 22, 2006, 7:19pm UTC](https://www.ruby-forum.com/t/mvc-architecture/64167/1 "2006-06-22T19:19:03Z")

</div>

Hi,  
I want to creat a GUI accessible via the web with ruby to interface some  
matlab implementation … so I extended Ruby with C++ and then matlab 🙂  
that works perfectly: I have finaly a Ruby class I can call whenever I  
want to lunch my matlab algorithm 😉  
the point is now I have to make the GUI in HTML with Rubby on rails and  
Damn! I don’t get how works the MVC architecture in Ruby (I already used  
a PAC architecture with JAVA) but with rails … I don’t get when I can  
call my function ☹

I create a model (where my Ruby/matlab class is called) but how I am  
supposed to call this functin from the view as far I don’t have any  
controler object in the view (it’s just a html page) … so what I tryed  
from the view to call a function in the controler which called the  
function of the model !  
but rails want to put a html page with the name of the function !!!

To summury… how I can call my Ruby/matlab function from the web page  
to execute code ??

Thanks  
Jerome

---

<div class="post-metadata">

**Author:** ![jerome](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@jerome](https://www.ruby-forum.com/u/jerome)\
**Post date:** [June 22, 2006, 11:42pm UTC](https://www.ruby-forum.com/t/mvc-architecture/64167/2 "2006-06-22T23:42:47Z")

</div>

Jerome wrote:

> Hi,  
> I want to creat a GUI accessible via the web with ruby to interface some  
> matlab implementation … so I extended Ruby with C++ and then matlab 🙂  
> that works perfectly: I have finaly a Ruby class I can call whenever I  
> want to lunch my matlab algorithm 😉  
> the point is now I have to make the GUI in HTML with Rubby on rails and  
> Damn! I don’t get how works the MVC architecture in Ruby (I already used  
> a PAC architecture with JAVA) but with rails … I don’t get when I can  
> call my function ☹
> 
> I create a model (where my Ruby/matlab class is called) but how I am  
> supposed to call this functin from the view as far I don’t have any  
> controler object in the view (it’s just a html page) … so what I tryed  
> from the view to call a function in the controler which called the  
> function of the model !  
> but rails want to put a html page with the name of the function !!!
> 
> To summury… how I can call my Ruby/matlab function from the web page  
> to execute code ??
> 
> Thanks  
> Jerome

You should probably do a Ruby on Rails tutorial to learn the basics.  
First of all controllers are required. You cant serve a page without a  
controller. In short:

Controllers:  
Handles the request and prep any variables the view may need. Alter the  
database in anyway that is necesary by communicating with the model.

Models:  
Represents units of data. the class “Product” represents the “products”  
table, and “Product.new” creates a product object representing a single  
row in that table.

Views:  
Display the HTML output. Views access the variables passed to them from  
the controller in order to format the output.

and also

Libraries:  
Modules and Classes that offer functionality but aren’t representative  
of a data set like a model. You should probably stick your matlab class  
here by adding it to the “lib” directory in your rails app.

in code:

#controller app/controller/home\_controller.rb  
class HomeController \< ApplicationController  
def index  
@matlab = MatLab.new(‘some’, ‘params’)  
end  
end

#view app/views/home/index.rhtml

MatLab output: \<%= @matlab.display %\>

Now to call the “index” action, go to “[http://domain.com/home/index](http://domain.com/home/index)” or  
for short “[http://domain.com/home/index](http://domain.com/home/index)”.

---

<div class="post-metadata">

**Author:** ![jerome](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@jerome](https://www.ruby-forum.com/u/jerome)\
**Post date:** [June 27, 2006, 1:16am UTC](https://www.ruby-forum.com/t/mvc-architecture/64167/3 "2006-06-27T01:16:32Z")

</div>

Alex W. wrote:

> Jerome wrote:
> 
> > Hi,  
> > I want to creat a GUI accessible via the web with ruby to interface some  
> > matlab implementation … so I extended Ruby with C++ and then matlab 🙂  
> > that works perfectly: I have finaly a Ruby class I can call whenever I  
> > want to lunch my matlab algorithm 😉  
> > the point is now I have to make the GUI in HTML with Rubby on rails and  
> > Damn! I don’t get how works the MVC architecture in Ruby (I already used  
> > a PAC architecture with JAVA) but with rails … I don’t get when I can  
> > call my function ☹
> > 
> > I create a model (where my Ruby/matlab class is called) but how I am  
> > supposed to call this functin from the view as far I don’t have any  
> > controler object in the view (it’s just a html page) … so what I tryed  
> > from the view to call a function in the controler which called the  
> > function of the model !  
> > but rails want to put a html page with the name of the function !!!
> > 
> > To summury… how I can call my Ruby/matlab function from the web page  
> > to execute code ??
> > 
> > Thanks  
> > Jerome
> 
> You should probably do a Ruby on Rails tutorial to learn the basics.  
> First of all controllers are required. You cant serve a page without a  
> controller. In short:
> 
> Controllers:  
> Handles the request and prep any variables the view may need. Alter the  
> database in anyway that is necesary by communicating with the model.
> 
> Models:  
> Represents units of data. the class “Product” represents the “products”  
> table, and “Product.new” creates a product object representing a single  
> row in that table.
> 
> Views:  
> Display the HTML output. Views access the variables passed to them from  
> the controller in order to format the output.
> 
> and also
> 
> Libraries:  
> Modules and Classes that offer functionality but aren’t representative  
> of a data set like a model. You should probably stick your matlab class  
> here by adding it to the “lib” directory in your rails app.
> 
> in code:
> 
> #controller app/controller/home\_controller.rb  
> class HomeController \< ApplicationController  
> def index  
> @matlab = MatLab.new(‘some’, ‘params’)  
> end  
> end
> 
> #view app/views/home/index.rhtml
> 
> MatLab output: \<%= @matlab.display %\>
> 
> Now to call the “index” action, go to “[http://domain.com/home/index](http://domain.com/home/index)” or  
> for short “[http://domain.com/home/index](http://domain.com/home/index)”.

Thanks for your reply 🙂  
I try what you said, and guess I begin to understand better but I have a  
problem of loading ! I import the class in charge of interfacing the  
library by ‘require’ but all the time it make an error … the path is  
good as far as if I just make the require in a file and then execute  
function the program execute !  
(but the point is by the web the path is not the same it should be  
http://\>…) so there is anything to do to set path where rails look ?  
thanks,

Jerome
