November 16, 2009
November 10, 2009
Rails Sortable Draggable params
Went around in circles a bit today implementing a barely-fancy list-to-list drag 'n sort. I don't do much Ajax usually, so I tend to lose my place, forget little things, and basically keep my Googling skills in tip-top shape to make up for my shoddy memory.
Anyway, enough backstory. You gotta use a word when id'ing your elements in sortable_element. It doesn't even matter what you use:
<li id="adfasjkd_<%= partialname.id %>">
(or however you're generating unique IDs for your LIs)
...as long as you have <ul id="flarfydarf">, Rails seems to be smart enough to chop whatever is not unique in the LI ID and throw it into params[:flarfydarf].
There are plenty of older tutorials out there with regexes in js functions inside the Ajax business, but I don't have any of that and Rails is finding my IDs just fine. Go figure.
Anyway, enough backstory. You gotta use a word when id'ing your elements in sortable_element. It doesn't even matter what you use:
<li id="adfasjkd_<%= partialname.id %>">
(or however you're generating unique IDs for your LIs)
...as long as you have <ul id="flarfydarf">, Rails seems to be smart enough to chop whatever is not unique in the LI ID and throw it into params[:flarfydarf].
There are plenty of older tutorials out there with regexes in js functions inside the Ajax business, but I don't have any of that and Rails is finding my IDs just fine. Go figure.
Labels:
magic
May 26, 2009
March 21, 2009
Doing it right, part 1
Just so I don't just come off as a cantankerous fool, I'm posting about AuthLogic, an authentication plugin for Rails. I haven't used it yet, but looking at their github page it seems apparent that they value decent documentation. Much better than the two-line READMEs that too many projects throw up there.
March 11, 2009
March 6, 2009
Rails Forum annoyance
Check it out.
You want to read some Rails goodness at the awesome Rails Forum so you're gonna log in, right? You type in your email address or username, finishing the first of three steps. You aren't my mom, or your grandfather, or any of the other myriad computer users and/or internet logger-inners, so what you don't do after this is reach over for the mouse and click on the password field. We've seen those people, and it's fine for them, but we are power users and possibly even touch-typists. We want to read, we want to help, and we want to get past the login. Without the mouse. So after typing our email address, we hit the Tab key to hop on over to the password field so we can authenticate and be on our way.
Well, maybe.
You want to read some Rails goodness at the awesome Rails Forum so you're gonna log in, right? You type in your email address or username, finishing the first of three steps. You aren't my mom, or your grandfather, or any of the other myriad computer users and/or internet logger-inners, so what you don't do after this is reach over for the mouse and click on the password field. We've seen those people, and it's fine for them, but we are power users and possibly even touch-typists. We want to read, we want to help, and we want to get past the login. Without the mouse. So after typing our email address, we hit the Tab key to hop on over to the password field so we can authenticate and be on our way.
Well, maybe.
February 28, 2009
ow my eyez II
Very common in the world of Ruby on Rails is the 40 character content block. My favorite is the last snippet where the whole middle of the text is off the right edge. What was it that Linus said about indentation levels? At any rate, I'm pretty sure this came about from people testing their layouts only on a 12" laptop in a coffee shop somewhere. "Perfectamundo," they say to themselves.
February 26, 2009
February 21, 2009
brokontrollers
Here's a nice one. Do try to include the controllers you're calling from your app. All of them, even the important ones.
I know it's fun to get all NIH and to write your own everything, but there's no pride in workmanship when the thing you are presumably basing your career on (or at least hobby) is so flimsy. But then again, I wouldn't have anything to rant about if people paid attention to this concept.
I guess what I'm saying is that if you don't give a crap, update your robots.txt to keep Google away.
I know it's fun to get all NIH and to write your own everything, but there's no pride in workmanship when the thing you are presumably basing your career on (or at least hobby) is so flimsy. But then again, I wouldn't have anything to rant about if people paid attention to this concept.
I guess what I'm saying is that if you don't give a crap, update your robots.txt to keep Google away.
February 17, 2009
calendar_date_select
It's tried and true, light and airy, funky and fresh, and somewhat poorly documented. This may be a consequence of my n00bie-ness, or that my history is with the admirably-documented FreeBSD and Perl worlds. I'll chalk it up to noobage, though, since many many people seem to be happy with this state of affairs.
The "calendar_date_select" plugin is a nice little widget for generating dates and times for your forms. It pretty much drops in and spits whatever date and time you click on back at your server. I've used it plenty, I've been happy with it, and I think it looks decent out of the box. The problem, so to speak, is illustrated best by the project's own author.
Rather than, you know, actually write docs, the author drops the ball until some clown makes an entire app that does...something. I don't know, because perhaps unlike a lot of people I read faster than I can download and run something like this. I mean, it may indeed be the best form of documentation ever conceived, but I'm skeptical. What happened to just describing the plugin's behavior? It seems like so many Ruby on Rails people are starving for some kind of validation, recognition...something. Crappy screencasts ("...uh...function goes here, and...uhm...tap tap tap...see?") vie for SEO manhood, and everybody and their baby brother takes it upon themselves to package link un-underliners as plugins that are AWSUM and A TOTAL TIMESAVER. Really guys, just drum up some freelance gigs already. Not everyone gets to be Ryan Bates (who, contrary to your apparent perception, obviously edits and, yes, "produces" his 'casts). Posting your demo app on github might let you loosen your ethics enough to call yourself a Rails "contributor," but anybody with a clue should know better.
But I digress. An additional downside of the attitude that a name has to be associated with every bit of help offered is that there is a proliferation of "demo apps" that are supposed to substitute for documentation. At the above URL you will read the words, "The DEMO is the largest source for documentation." Hilarious, right? WTF kind of info-balkanization are we heading toward? Is Rails 2.3 going to do this for itself? "Want to know what has changed in 2.3? Install and run this thingy here!" That the given docs on that page look like something scrawled out somewhere back around v0.0.0.1 only adds to the insult. Couldn't be bothered!
No, I just want to see a file called CHANGELOG.
FYI, if you're looking for bits and bobs and details on CDS, there is a page that has helped me. Some comments indicate that this in fact may be the demo app I've been railing against, but who knows. I always find it through some random comment link because every one of the "official" CHECK OUT DA DEMO links on project pages are always dead. Heck, the electronicnicholas link may be dead by the time you find this page, but it's what I have to click and backtrack to find whenever I'm looking for details. Why? Because the plugin's docs suck.
The "calendar_date_select" plugin is a nice little widget for generating dates and times for your forms. It pretty much drops in and spits whatever date and time you click on back at your server. I've used it plenty, I've been happy with it, and I think it looks decent out of the box. The problem, so to speak, is illustrated best by the project's own author.
Rather than, you know, actually write docs, the author drops the ball until some clown makes an entire app that does...something. I don't know, because perhaps unlike a lot of people I read faster than I can download and run something like this. I mean, it may indeed be the best form of documentation ever conceived, but I'm skeptical. What happened to just describing the plugin's behavior? It seems like so many Ruby on Rails people are starving for some kind of validation, recognition...something. Crappy screencasts ("...uh...function goes here, and...uhm...tap tap tap...see?") vie for SEO manhood, and everybody and their baby brother takes it upon themselves to package link un-underliners as plugins that are AWSUM and A TOTAL TIMESAVER. Really guys, just drum up some freelance gigs already. Not everyone gets to be Ryan Bates (who, contrary to your apparent perception, obviously edits and, yes, "produces" his 'casts). Posting your demo app on github might let you loosen your ethics enough to call yourself a Rails "contributor," but anybody with a clue should know better.
But I digress. An additional downside of the attitude that a name has to be associated with every bit of help offered is that there is a proliferation of "demo apps" that are supposed to substitute for documentation. At the above URL you will read the words, "The DEMO is the largest source for documentation." Hilarious, right? WTF kind of info-balkanization are we heading toward? Is Rails 2.3 going to do this for itself? "Want to know what has changed in 2.3? Install and run this thingy here!" That the given docs on that page look like something scrawled out somewhere back around v0.0.0.1 only adds to the insult. Couldn't be bothered!
No, I just want to see a file called CHANGELOG.
FYI, if you're looking for bits and bobs and details on CDS, there is a page that has helped me. Some comments indicate that this in fact may be the demo app I've been railing against, but who knows. I always find it through some random comment link because every one of the "official" CHECK OUT DA DEMO links on project pages are always dead. Heck, the electronicnicholas link may be dead by the time you find this page, but it's what I have to click and backtrack to find whenever I'm looking for details. Why? Because the plugin's docs suck.
February 13, 2009
acts_as_state_machine
Everybody loves restful_authentication, right? RIGHT? Well, along with having plenty of tutorials to get your users registering and logging in, if you want activation you need the acts_as_state_machine plugin. The secret to installing this is to ignore The Google, or else you may get something like:
$ script\plugin install acts_as_state_machine
svn: Connection closed unexpectedly
svn: Can't connect to host 'errtheblog.com': No connection could be made because the target machine actively refused it.
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
Plugin not found: ["acts_as_state_machine"]
$
Another Google-recommended technique is to install from any number of alternate sites that have hosted this seemingly-hobo plugin over the past couplefew years. They have all been mentioned at one time or another.
However, the secret is to read the output of the plugin install for restful_authentication. Here (as of 2/2009) you will find that the right way to install acts_as_state_machine is (currently):
$ svn export http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk vendor/plugins/acts_as_state_machine
That's all one line, BTW (Blogger sux). Why we have to do an svn ex for something like this is beyond me, but I figure the (typically lazy OSNAP) developers have a good reason. Live and learn!
At least this didn't end in the typical heartbreak of a rails site returning code 500 errors, or a plugin that was abandoned two years ago. Huzzah!
$ script\plugin install acts_as_state_machine
svn: Connection closed unexpectedly
svn: Can't connect to host 'errtheblog.com': No connection could be made because the target machine actively refused it.
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
svn: Connection closed unexpectedly
Plugin not found: ["acts_as_state_machine"]
$
Another Google-recommended technique is to install from any number of alternate sites that have hosted this seemingly-hobo plugin over the past couplefew years. They have all been mentioned at one time or another.
However, the secret is to read the output of the plugin install for restful_authentication. Here (as of 2/2009) you will find that the right way to install acts_as_state_machine is (currently):
$ svn export http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk vendor/plugins/acts_as_state_machine
That's all one line, BTW (Blogger sux). Why we have to do an svn ex for something like this is beyond me, but I figure the (typically lazy OSNAP) developers have a good reason. Live and learn!
At least this didn't end in the typical heartbreak of a rails site returning code 500 errors, or a plugin that was abandoned two years ago. Huzzah!
Subscribe to:
Posts (Atom)