I have my list view filtering rows shown within the table
tags like
most of the introductory tutorials do. As I’m adding a few dozen entries
I’m noticing the standard scaffolding pagination doesn’t pick up the
number of rows from the filter since it is not being passed the number
of rows returned within the scope of the filter statement.
From a tactical point I’m wondering if there’s a proper way to approach
this. Should I move my row filter statements into a a method within a
helper that can then be called at top of the list view for the entire
page? Or perhaps separate partial view files should be used with
different filter statements at top of each? Or perhaps there’s someother
way I’m not seeing right off.
I’m imagining the pagination link_to’s will need to include the filter
variables so they are persistent also. So ":s => “Summer”, :c =>
“Beverage”, :t => “Cold” creates urls with added
“?s=Summer&c=Beverages&t=Cold” for example. Is there a prettier way to
persist the variables? Maybe iterate through possible #? of params
within the method?
This way paginate should be getting the rows from the @snacks find
query, right?
I’m getting “undefined method `season’ for #Array:0x24e6b84”
currently. It doesn’t seem to recognize the current rows season_id table
column for some reason, even if I explicitly use @snacks.season_id.
Well I’ve been working at this for about five hours now and I can’t seem
to get beyond the basics in RoR. I’ve read and reread through a couple
more tutorials, dug through my Pick Axe and Ruby for Rails books, and
tried a few more experiments but still not making any progress. It’s
great seeing how a basic application can be created in 15 minutes in the
tutorials but creating a more evolved app seems to be a much more
complicated process.
To try and further my progress I’ve posted a live working example with
code and notes so people can see what I am describing. It’s currently
posted at: Freelance Web Designer.
This is a clean rewrite starting over from the beginning so hopefully
it’s straight forward. None
Hopefully someone knows how I can get the pagination to work properly
while showing only certain rows.
different filter statements at top of each? Or perhaps there’s someother
way I’m not seeing right off.
I’m imagining the pagination link_to’s will need to include the filter
variables so they are persistent also. So ":s => “Summer”, :c =>
“Beverage”, :t => “Cold” creates urls with added
“?s=Summer&c=Beverages&t=Cold” for example. Is there a prettier way to
persist the variables? Maybe iterate through possible #? of params
within the method?
I store my filter conditions into a session variable, since it gets
really ugly when you’ve got more than a half a dozen filtering
conditions.