# Newbea MVC question?

**URL:** <https://www.ruby-forum.com/t/newbea-mvc-question/130535>\
**Category:** Rails\
**Created:** [February 29, 2008, 3:57am UTC](https://www.ruby-forum.com/t/newbea-mvc-question/130535 "2008-02-29T03:57:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 29, 2008, 3:57am UTC](https://www.ruby-forum.com/t/newbea-mvc-question/130535/1 "2008-02-29T03:57:22Z")

</div>

Hi RoR Developers,

I’m quite new to MVC model , I have some pretty basic questions that I  
hope some of you can answer.  
I have two controllers and one view page like below, I want to call  
variables from report\_controller in view page. in fact view page for  
sheet\_controller and I m wondering if there is a way to reach that  
variables from report\_controller in the view page of sheet.  
another question is also quite same. how can I call the variable from  
report\_controller, in sheet\_controller.

there is a “project” folder in controller  
2 controller(Sheet\_controller, report\_controller)  
and  
1 views - for sheet\_controller

thanks

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 29, 2008, 5:11am UTC](https://www.ruby-forum.com/t/newbea-mvc-question/130535/2 "2008-02-29T05:11:02Z")

</div>

Ibrahim D. wrote:

> Hi RoR Developers,
> 
> I’m quite new to MVC model , I have some pretty basic questions that I  
> hope some of you can answer.  
> I have two controllers and one view page like below, I want to call  
> variables from report\_controller in view page. in fact view page for  
> sheet\_controller and I m wondering if there is a way to reach that  
> variables from report\_controller in the view page of sheet.  
> another question is also quite same. how can I call the variable from  
> report\_controller, in sheet\_controller.
> 
> there is a “project” folder in controller  
> 2 controller(Sheet\_controller, report\_controller)  
> and  
> 1 views - for sheet\_controller
> 
> thanks

Controller methods automatically pass their instance variables to their  
respective views that they are rendering…

For example, if you have the controller method  
def new  
@car = Car.new  
end

in your new.html.erb view, you will have access to this instance  
variable…  
\<%= @car.name %\>

As for your other questions, A controller doesn’t access variables from  
another controller…

The abbreviated process in a nutshell is this,  
A request comes in  
routing dispatches the request to a controller (to you, this controller  
is brand smacking new)

The controller is responsible for pulling up any models it needs,  
figuring out what view should be displayed and preparing the data to be  
consumed by the view…

The models can only see into other models (and the db), they don’t deal  
with any strings, controller state, or views

Views interact with models but don’t know anything about controllers or  
any business logic at all, all their code is primarily for displaying  
data

Controllers can forward requests to other controllers or back to  
themselves, but other than redirecting, they have no other business with  
other controllers.

I hope this gave you a birds eye view. May I suggest you pick up a good  
RoR book to get you more familiar with MVC.

ilan

---

<div class="post-metadata">

**Author:** ![casid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/47e85d/32.png) [@casid](https://www.ruby-forum.com/u/casid)\
**Post date:** [February 29, 2008, 5:45am UTC](https://www.ruby-forum.com/t/newbea-mvc-question/130535/3 "2008-02-29T05:45:11Z")

</div>

Thank you ilan,
