Dynamic Data and Proxy Pages

Hi,
I’ve got a problem I’m working with. I would like to do this:

Here are my proxy pages:

data.states.states.each do |state, entries|
  proxy "/states/#{state['name'].downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.html", "/states/template.html", :locals => { :state => state, :statename => state.name }, :ignore => true
end

Yaml file has a list of states

states:
  - name: Michigan
    country_id: '49'
    abbr: MI
  - name: South Dakota
    country_id: '49'
    abbr: SD
  - name: Washington
    country_id: '49'
    abbr: WA
  - name: Wisconsin
    country_id: '49'
    abbr: WI

I then have another folder inside the data directory called entires. I have a file for entires per state like so (ie california.yaml, etc)

-
  category: "Test"
  name: "Test"
  full_address: "Test"
  address: "Testt"
  city: "Tulare"
  state: "CA"
  zipcode: "93274"
  country: "United States"
  phone: "999"
-
  category: "Test"
  name: "Test"
  full_address: "Test"
  address: "Testt"
  city: "Tulare"
  state: "CA"
  zipcode: "93274"
  country: "United States"
  phone: "999"

I’d like to loop through those entries on each of dynamically generated pages. Something like this:

<% data.entries.state.each do |f| %>
  do stuff here
<%end>

Thats the part I’m having some difficulty with. Anyone have any advice?

First you’ll want that proxy declaration to pass a local for abbr

Then something like this totally untested code in the template:

State <%= abbr %>:
<% data.entries.select{|e| e.state == abbr}.each do |e| %>
     stuff with e
 <% end %>

Thanks so much.

Think I got it here:

<% data.entries.select { |s| s == thisstate }.each do |e| %>
     <% e.each do |entry| %>
       <%= puts entry %>
     <% end %>
 <% end %>

It’s returning the hash in the console, I just can’t access the values I’ve tried most ways

<%= puts entry.business_name %>
<%= puts entry[:business_name] %>
<%= puts entry["business_name"] %>

Ahh nevermind, I got it.

<% data.entries.select { |s| s == thisstate }.each do |key,value| %>
<% value.each do |entry| %>
    <%= puts entry.business_name %>
<% end %>
<% end %>

Although this seems like it could be done better.

Thanks for your help!