Ibrahim Dogru 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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---