So I have three models: Topic, Post and Paragraph. Each Topic has many Posts and each Post has many Paragraphs. What I need to achieve is to sort the Paragraphs by Topic on paragraphs/index.html.erb
.
I of course have the dropdown menu including all the topics:
<form>
<select>
<% @topics.sort { |a,b| a.name <=> b.name }.each do |topic| %>
<option><%= topic.name %></option>
<% end %>
</select>
<input type="submit">
</form>
I followed the advice on: Filter results on index page from dropdown, but I couldn't manage to come up with a way to connect Topic params first to Post and then to Paragraph. I simply have no idea how to go with it, and there doesn't seem to be many examples out there, so any ideas are hugely appreciated.