Make your decisions easier!
Argue: from Latin arguere (“to make clear”)
The point of argument is not to show what’s correct, far less to show who’s correct. Argument is used to make clear, to clarify the evidence and logic around a point at issue.
I like things to be clear, but that really doesn’t say that I like to argue. Argument is hard work, conducted according to techniques that have been tested for at least 2,500 years. Liking to argue is, for me, like enjoying ditch-digging (I don’t.) It’s work. Worthwhile work, when done properly, but too much effort to waste on squabbling.
Like soccer, argument is only worthy of the name when it goes by the rules. Soccer without rules is just a tedious squabble over a ball. Argument without rules is just plain tedious. Even when an opponent proves your case for you, it is tedious to watch.
So, if one side is playing soccer, and the other is just squabbling over a ball, it is just a squabble. It takes two to make an argument, but only one to turn it into a squabble by ignoring the rules.
Many times when I stop responding to Facebook posts, it is because my opponent has made such a cringe-worthy logical blunder that it is too painful to continue. Besides, leaving that blunder as the last post on a thread means that I actually have the closing argument, even though it is written by my opponent.
So, do I enjoy argument? I can appreciate a good argument, but I have no time for the usual barrage of ad hominem, straw men, and non sequiturs that so often turn it into a mere squabble.
I have some questions about how the NIH sees priorities:
Is it reasonable to spend 6x more on 174. smallpox (0 cases since 1980) than 226. CFS/ME? (1 million people, right now).
Or 141. anthrax — how many cases do you know, personally? Yes, with a few rooms full of specialized equipment and a half-dozen experts in various fields it can be weaponized. Otherwise, it’s “wool sorter’s disease,” and you have to catch it from a sheep. Most years, no one does.
For that matter, $72 million for 140. Adolescent Sexual Activity? What exactly are we accomplishing, there?
Again, I am trying to make this the most understandable code, without any regard whatsoever for elegance. In a previous post I made a do-nothing uploader, just to get some feel for the whole HTML5 file upload process. I recommend that you also make one and play with it to get a good feel for what goes on.
This time, we’re actually going to upload, attach, and display files using Paperclip and Rails 4.
The Summit County Engineer keeps track of Road Records. A Road Record can have a bunch of attached files of varying formats, e.g. tif, pdf, jpg, and doc. There’s a bunch of fields about which road, which section, what kind of work, etc. These, you can ignore.
For this tutorial (and my app,) I’m going to call the attached files Road Record Assets.
For the most part, this is just typical Paperclip. Most of the non-typical work gets done in the road_records_controller, so let’s look at that first. (Rails 4: turn off protect_from_forgery for the add_assets function)
It just adds a new RoadRecordAsset for every file it gets. The fact that the file gets stored in /tmp/ for a bit gives you the chance to rename it, sanitize it, or whatever before it actually gets attached. Don’t forget to add the route:
The RoadRecord model is simplicity itself.
And the RoadRecordAsset model is nearly as simple.
Notice that you can do all the usual Paperclip magic, just as you’re used to.
All that’s left is the upload part, which is very similar to what was shown in the last post:
I scrounged all over the web for bits of this; hopefully, you won’t have to. Thanks to all those who posted demos, tuts, and gems!
Every time I look at the transistor radio in my workshop, I think about my Dad. Well, not the radio, really, but the box. See all the wear and tear? That radio box is about 10 years old.
Dad’s been gone for a few years, now, but Dad would do that. He’d keep things in the original box until the box disintegrated. It’s a good idea for several reasons:
- Labels the item
- Preserves the instructions
- You know where to get parts (if anything is actually repairable.)
- It makes odd-shaped items fit neatly on the shelf and in drawers.
However, I don’t think any of those reasons are the real motivation. Maybe it goes back to when the container was a part of the product. Like, back when the boxes for tools looked nicer than the boxes for jewellery look now.
Even more than that was just Dad’s impulse to preserve, to keep things nice. Anyway, when I see that old box, I think Dad likes to see it, too.
Then the Lord said, “How great is the outcry against the elitists and their government toadies. They cry out against the poor and say that they toil not, neither do they spin. I must go down and see who is Getting Away With Something.”
Abraham remained standing before the Lord. Then Abraham came near and said, “Will you indeed sweep away the deserving with the wicked? Suppose there are fifty within the Safety Net who couldn’t meet their medical bills; will you then sweep away the Safety Net from the fifty deserving who are in it? Far be it from you to do such a thing, to cut off the deserving with the wicked, so that the deserving fare as the wicked! Far be that from you! Shall not the Judge of all the earth do what is just?”
And the Lord said, “If I find fifty deserving within the Safety Net, I will leave the whole plutocracy in place for their sake.”
Abraham answered, “Let me take it upon myself to speak to the Lord, I who am but dust and ashes. Suppose five of the fifty deserving could have paid their medical bills, but now they have lost their jobs? Will you destroy the whole Safety Net for lack of five?” And he said, “I will not destroy it if I find forty-five there.”
Again he spoke to him, “Suppose forty are found there who owe on student loans for a degree that the elite value not?” He answered, “For the sake of forty I will not do it.”
Then he said, “Oh do not let the Lord be angry if I speak. Suppose thirty are found there who bore their children rather than abort them?” He answered, “I will not do it, if I find thirty there.”
He said, “Let me take it upon myself to speak to the Lord. Suppose twenty are found there who are working, but cannot earn a just wage?” He answered, “For the sake of twenty I will not destroy the Safety Net.”
Then he said, “Oh do not let the Lord be angry if I speak just once more. Suppose ten are found there whose retirement was taken to pay executive bonuses?” He answered, “For the sake of ten I will keep it in place.”
The two angels came to the plutocracy in the evening, and Lot was in a place of honor within the plutocracy. When Lot saw them, he rose to meet them, and bowed down with his face to the ground. He said, “Please, my lords, let me treat you as equals, even though you cannot prove that you are deserving.” They said, “No; we will spend the night in this town square.”
But he urged them strongly; so they turned aside to him and entered his house; and he made them a feast, and baked unleavened bread, and they ate.
But before they lay down, the men of the plutocracy, both the elite and their toadies, all the people to the last man, surrounded the house; and they called to Lot, “Where are the men who came to you tonight? Bring them out to us, so that we bring them into the plutocracy. We wish to make unto them loans instead of Free Stuff, that they may become indentured servants unto us.”
Lot went out of the door to the men, shut the door after him, and said, “I beg you, my brothers, do not act so wickedly. Look, I have two daughters who have not yet entered the plutocracy; let me bring them out to you. The younger will be an unpaid intern unto you; and the elder will hew wood for 30 hours and draw water for another 30 so that even the Safety Net avail her not. Only do nothing to these men, for they have nothing to yield up to you.”
But they replied, “Stand back!” And they said, “This fellow came here from outside, and his charity is given freely to those who cannot prove they deserve it! Now we will deal worse with you than with them.” Then they pressed hard against the man Lot, and threatened him with foreclosure.
But the men inside Lot’s house reached out their hands and brought Lot into the house with them, and shut the door. And they smote the men who were at the door of the house, both small and great, so that they were unable to find who actually held the mortgage on Lot’s house. The first waved papers that shew him as the owner of Lot’s house, but another had papers that shew the first had failed to file other papers, and there was great confusion.
Then the men said to Lot, “Have you anyone else here? Sons-in-law, sons, daughters, or anyone you have in the plutocracy — bring them out of it. For we are about to destroy this plutocracy, because the outcry against its people has become great before the Lord, and the Lord has sent us to destroy it.” So Lot went out and said to his sons-in-law, who were to marry his daughters, “Up, get divested now; for the Lord is about to destroy this plutocracy.”
But his sons-in-law said, “Are you jesting? It has always been this way. What would take its place? Within six months, all the shekels will be right back in the same purses.”
When the light dawned, the angels urged Lot, saying, “Get out, or else you will lose everything in the downturn.” But he lingered; so, the Lord being merciful to him, the men bought him out and left him outside the plutocracy. Likewise, they bought out his wife and daughters from their financials and credit default swaps. When they had bought them all out, they said, “Just forget this whole plutocracy; do not look back or try to save any part of it; flee to the hills, or else your substance will be consumed.”
And Lot said to them, “Oh, no, my lords; your servant has found favor with you, and I am glad to get away with something; but I cannot just shut down completely, for fear the downturn will overtake me and I will go broke. Look, that Zoar co-op is easy enough to invest in, and it is a little one. Let me put my investments there — is it not a little one? — and my assets will be saved!” They said to him, “Very well, I grant you this favor too, and will not overthrow the co-op of which you have spoken. Hurry, invest there, for I can do nothing until you are fully vested there.” Therefore the co-op was called Zoar. The light had fully dawned on the earth when Lot became fully vested in Zoar.
Then the Lord rained on the elitists and their servile government sulfur and fire out of heaven; and he overthrew that plutocracy, and all that elite, and every transaction that they corrupted. But Lot’s wife, behind him, couldn’t resist selling short on the downturn, and she became a pillar of salt.
Abraham went early in the morning to the place where he had stood before the Lord; and he looked down where the elitists and their servile governments had been and toward all the land of the plutocracy and saw the smoke of them going up like the smoke of a furnace.
So it was that, when God destroyed the elitists and their government toadies, God remembered Abraham, and sent Lot out of the midst of the downturn, when he overthrew the plutocracy in which Lot had invested, because Lot had showed mercy to those who had not proven that they deserved it.
Whenever the safety net is discussed, even among Christians, the conversation always gets around to welfare cheats, if it doesn’t start there. Well, of course there are some, but what of it?
- God doesn’t limit His charity to the deserving, so we can’t, either. As G. K. Chesterton points out, if someone deserves a benefit, that it is a demand on us for justice rather than an opportunity for us to show charity.
- God seems to set great value on preserving even very imperfect things. He doesn’t burn down the city to exterminate some rats; nor plough up the wheat to kill the tares. Helping truly needy people, even if they were in the minority, takes precedence over preventing abusers from Getting Away With Something.
- God does not give money and power to certain people because they possess some superior wisdom or morality. The cost of one rich tax dodger, one unearned government subsidy, or one no-bid defence contract can easily exceed the cost of all welfare programs put together, but the discussion almost never turns to the sins of the wealthy and powerful.
Well, if your results are ordered by last name, which page do you click to see “Phillips” ?
<<Page 1, 2, 3 . . . < 15, 16, 17 > . . . 32, 33 >>
Go on, guess!
Wouldn’t this be easier?
<< Appleby, Brown, Busskirk . . . < Lundy, Numps, Psederton > . . . Wycliffe, Zetos >>
See? With proper page labels you can find the page in a couple of clicks.
Page numbers only make sense when there is no natural order to the results. A true search (returning results in “relevance” order, say) is forced to use page numbers, because the results don’t have any consistent labels. However, there’s no excuse for making users guess which page number is the “P’s” when we’re filtering and sorting a “Last Name” column.
It’s normal to have some kind of default ordering, so that should be used to label the pages. If we’re talking about people, family name is a good default order. There is a demo at http://search-results-demo.herokuapp.com/, and the default order is family_name.
However, we could use “Supervisor.” If you click the “Supervisor” link in the first table of search terms, you’ll see that the results are paginated by supervisor’s name. (Hover over “Pick Page” in the brown pagination menu.)
Whatever we use, the pages should be labeled with the value of that field for the first record on the page.
Here’s One Way To Do Meaningful Pagination
Use whatever paginator you like. Kaminari is fine.
We’ll need to know which field the results are sorted by (there’s a little extra code to put the sorted field on the left if it’s an optional field, but that’s another tutorial):
Then we can get the contents of the first record on each page.
It’s simpler just to use the same page length and select the first field on each page.
So, the controller looks like this:
Then, it’s just a matter of creating the navigation display.
The view calls for the pagination navigation display if there is more than one page of results
There’s a little helper method:
which calls the actual pagination navigation partial:
And, finally, style it all:
There! It’s a bit of work, but it really makes user life easier.