Trying to store objects in an array to iterate through in the view.
In my controller:
def expire
@search = Search.new(search_params)
if @search.valid?
@clients = []
@allClients = #value from REST API
@allClients.each do |client|
@clientele = Clientele.new
@clientele["exp"] = client.experience ##Also tried @clientele.exp = client.experience
@clientele["email"] = client.email ##Also tried @clientele.email = client.email
@clients.push(@clientele)
end
end
end
class Clientele
def exp
end
def email
end
end
In my view nothing shows up and showing the @clients array gives an empty array:
<% @clients.each do |client| %>
<%= client.exp %>
<%= client.email %>
<% end %>
<%= clients %> #=> []
I'm not sure what I'm doing wrong, I can't seem to just create a temporary object to store values in and store it into an array. Any help or suggestions would be helpful.