So, I need Rails to display the values of a query string value (a last
initial). The current controller looks like this:
def index
@letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
if params[:id]
@initial = params[:id]
@pages, providers = paginate(:providers,
:conditions => ["last_name LIKE
?",
@initial+''%''],
:order => "last_name,
first_name")
@providers = providers.collect { |provider| provider }
@levels = Level.find(:all)
end
end
The view looks like this:
<% if @pages %>
<p>
Found <%= pluralize(@pages.item_count, "match") %>.
</p>
<% end %>
<% for level in @levels %>
<% for provider in level.providers %>
<% for provider in @providers %>
display various provider attributes
<% end %>
<% end %>
<% end %>
<% end
The results of this view does correctly display the number of results
for the query, but it displays all the values for the providers,
regardless of how many match the given query.
Obviously, in the providers model, there is a has_and_belongs_to_many
:levels
Thanks for any help on this.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---