i have a model with 35000 entries in the database. I was using a unique string as the primary key. Right now I am using the order method to return the model objects in
order. I'd like to know what is good practice ( efficient ) and how to return X entries at a time instead of all at once. Right now I'm using the index method of a controller along with the order method to return the entries, and then iterating through them in the view.
class StoreController < ApplicationController
def index
@dicts = Dict.order(:key)
end
end
<h1>Store#index</h1>
<p>Find me in app/views/store/index.html.erb</p>
<% @dicts.each do |word| %>
<div class='entry'>
<%= word.key %>
</div>
<%end %>
I'd also like to know a little more about how conrtrollers work with the database. Is a new store controller instanced everytime a route is directed to it? If so am I continually querying the database for those 35000 entries, or is one instance of the controller generated, and one request made. I have read some of the rails guides, and read quite a bit of agile web dev with rails 4, but haven't found the answer to my questions. Do you think you know a reference you would recommend I read?