Re: [Rails] How to make an array available to all views.
On 10 March 2010 08:54, capsized <4chanarchive@gmail.com> wrote:
> Hi,
>
> I have an application layout that is used to create the general layout
> for all pages.
> However, I seem to struggle to find out how to declare variables like
> arrays so that they are available everytime that layout or its related
> partials are used.
>
> Putting @myarray = MyArray.all into every action in every controller
> doesn't seem very dry, so I guess I'm just looking for a very simple
> straighforward convention, but can't seem to find it documented
> anywhere or figure it out.
If it is literally something as simple as MyArray.all I believe there
is nothing wrong with calling the model direct from the view.
Colin
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home