MVC architecture

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 :slight_smile:
that works perfectly: I have finaly a Ruby class I can call whenever I
want to lunch my matlab algorithm :wink:
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 :frowning:

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

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 :slight_smile:
that works perfectly: I have finaly a Ruby class I can call whenever I
want to lunch my matlab algorithm :wink:
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 :frowning:

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” or
for short “http://domain.com/home/index”.

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 :slight_smile:
that works perfectly: I have finaly a Ruby class I can call whenever I
want to lunch my matlab algorithm :wink:
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 :frowning:

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” or
for short “http://domain.com/home/index”.

Thanks for your reply :slight_smile:
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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs