my app has user, photo, and state models.
a user belongs to a state and thusly has a state_id field,
a user has many photos.
I have the photos view set up as the home page.
I am trying to set up a select tag and form tag to filter through the
photos by which state is selected.
My files are:
<%= form_tag photos_path, :method => 'get' do%>
<%= select("state", "name", State.all.collect(&:name)) %>
<%= submit_tag "State" %>
<% end %>
if (params[:state] )
statesmen = State.find_by_name(params[:state][:name]).users
statesmen.each do |person|
@photos = Photo.where(:user_id => person.id)
My questions are 1
Is there a better way to collect the photos? Theres gotta be. Should I
just give the photo a state_id field?
Why can't I do it this way