Say array = [1,2,3]. You can display it in the view by just calling inside erb tag like this:
<%= array %> # [1,2,3]
if you want to iterate through it:
<% array.each do |a| %>
<%= a %> Mississippi.
<% end %> # 1 Mississippi. 2 Mississippi 3 Mississippi.
or use a helper method:
<%= a.to_sentence %> # 1, 2, and 3
As far as where to define them, it depends. If it's a static list, you can define them in the model like this:
class Foo < ActiveRecord::Base
BAR = [1,2,3]
end
then access them pretty much anywhere by calling
Foo::BAR
If you are only the array in that particular view, you can assign it to an instance variable in the controller like this:
class FooController < ApplicationController
def index
@array = [1,2,3]
end
end
then call it from view like this:
<%= @array %> # [1,2,3]