Posts tagged 'rails'
Despite my half-vow last week to try to write more, it doesn't seem to have worked out that way. I only consider myself to have missed a single day (Friday), but that's enough.
Thursday I left off having torn out my user auth and dropped in
devise; I was getting frustrated with it by the late hour I left, whenever that was. I finally got it working today, and even though it's one of those things that's really powerful once it's up and running, there's so much going on with rails and devise metaprogramming that it was hard to pin down where the weird behaviors were coming from.
Long story short: getting ajax sign-in working is highly non-trivial in devise, because it has a lot of expectations for how you'll be using it. There's no easy way to shove the user's account data down the pipe when logging in via ajax, and it's not clear from the documentation what's breaking.
It turns out, though, that you can call
:locationargument, and rails does not respect that unless the
:formatis html. So when trying to debug what appears to be a straightforward statement, using the suggestions written by the devise authors, you're led to fixate on a couple small lines of code that actually have nothing to do with your problem.
This is the double-edged sword of using a framework. Once you figure out enough of the gotchas to get things moving, you get a lot of reliability and power for free, but you're forced to either use things how they intend you to (in the given examples and configuration options) or hack up enough of the framework to bend it to your will.
Oh, well; that's out of the way. I may have to generate a toy project using straight rails and vanilla
deviseauthentication to see how it's supposed to work, because I'm not entirely happy with what I've got now. That seems to be the way of this latest phase of my final project: I've been adding things and discovering the limitations of a lot of the more robust options out there, and it's annoying.
One of the things I added to my portfolio recently is a set of progress bars representing my knowledge of different tools. I was reluctant to do this, because any progress number seems quite arbitrary, but I'm willing to venture that one thing that represents knowledge level is when you begin to get frustrated with a tool.
In fact, I'll put this forward: if we're all being honest, able to use something while using the documentation might be 10% knowledge; 20% would, then, be, able to complete simple tasks without reference to the documentation. 30% might be the point where you start saying "oh, this is neat!". At 40% you feel at ease; 50% would be the point where you have the documentation open, but you don't rely on it. By 60% you forget to even open the documentation, but at 70% you've got it open again because you're trying to do something that the tool just doesn't make easy. At 80% you're saying "oh, for god's sake"… at 90% you're patching the tool.
It's rough, but it's something. With this framework, my resume is a bit of a lie, but it's close to accurate so I suppose I can leave it. And by this measure, I'm at 80% with some things I wrote as 70%, and 40% on some 50%s.
I'm okay with this, in the end.
Spent most of the day today trying to make up for lost time, which doesn't really work but most of the day I had that level of speed. I left the office at 11:00 last night and midnight tonight, and got in a half-hour late this morning because there just isn't enough time.
A benefit to overthinking everything and going down blind alleys is that my bug-hunting skills are only getting better. After three productive hours prior to lunch doing… I barely remember, but something… I tried doing something a bit too clever (having to do with separation of concerns again), and didn't come up for air until after 6. From 6 to midnight I was plenty productive, but messing up like that still stings.
In brief: I monkey-patched the Backbone Router prototype to offer callbacks before and after routing, and then tried using those hooks to grab a user who wasn't logged in and redirect them to the login page (while preserving state). Once again, on my way home, I think I understand what I was doing wrong, and can see how to fix it, but I ended up ripping most of that code out and leaving it basically exactly how we were taught in the auth demo.
I still don't like having a
currentUserglobal, but for my app it's not a terrible idea, since you need to have some purpose coming to a blackboard-like site. It's not like your typical modern website, where there's generally some functionality that's meaningful even without an account, so… whatever.
Oh, so I remember now—one of the fastest ways to make me hate your website or app is to have data entry be painful. So I spent three hours making syllabus creation absolutely beautiful, modulo a couple tweaks, and ran into a bug that I couldn't figure out even with Tommy's help. Basically, I had the event creation success callback call a JQuery
focus()event on the first field in the form, and it kept losing focus after render. So I said to hell with it, and installed a
setTimeoutcall that waits 50ms then focuses back on the first field. Hacky, but resilient.
No matter what I do, more of these sorts of hacks creep into my codebase. But then I see things like when iOS autocompletes a word, then you press punctuation, it backspaces and writes the punctuation and a space instead of just inserting it at the previous position.
I can't decide if this says more about the UX rot of iOS or the inevitability of hacky solutions.
Tomorrow we're presenting again and I think I'm going to bum rush the core features, no matter how they look, rather than polish anything. I have a
TODO.mdfull of broken things, but that's just going to be the nature of the beast.
Wanna know what kind of day it's been? I just remembered that I didn't eat my breakfast. I packed it in my bag 16 hours ago.
I was actually going to post a partial update about my work over the weekend, but didn't manage to find the time. It might be a worthwhile task to do on my train commute, given that the normal sources of distraction are quite boring lately (although I suspect that others might think the same of my "content" on platforms such as fb).
Long story short: after running a couple errands on Saturday, I made it to the office by 6 pm, and worked straight through until about 2am, slightly tipsy and having learning a whole lot about how rails and backbone routes interact. There are a couple people who were here when I got here, and I had a very enriching time between talking through errors and feature development. I ended up bouncing a lot of ideas off of one guy in particular, and that helped me nail down a particularly complicated process that had been giving me fits.
Sunday, I woke up around 10 and started at the office around 2, and worked there for ten hours until the lack of running water in the building (long story) and the late hour drove me home. (I was also running on fumes, energy-wise). It was a long day of debugging, thinking through the backbone object model, and offering moral support to the other people working from the office.
I, by no means, have the most broken nor the most functional app, but I feel that I'm in a good place right now—which is good, since I'm setting my own pace :P I'm confident in the kernel of my project: every re-factor so far has been on the order of 5-20 lines of code, with a noticeably left-leaning Poisson distribution (i.e. more short patches than long).
Today, then, I woke up not sure what day it was, and I was somewhat disappointed to realize it was "only" Monday. When you work through the weekend, there's not much point trying to differentiate between each day. Nonetheless, today was better than a typical day at work, from my past life… this feels like just "what I do" now.
One thing that I like about the approach I've been taking toward development is that at every stage, my app works. I have yet to have a period, once I finished the core view, that adding a feature caused another feature to fail. Part of this is due to my deliberate approach to development, thinking through how the features will interact down the road, but most of it is due to a highly incremental process of grafting features on sensibly.
I do, however, wonder if I can keep this up.
It's telling about my state of mind that I tried using an Atom shortcut, namely cmd-enter, to insert a carriage return below the current line, and ended up instead sending my blog post off into the internets.
We've all been staring at text editors for nine hours (minus breaks and lunch) and it's been a long, albeit productive, day. I can tell what everyone's up to and no joke I'm behind… however, I haven't asked for technical help or code review in three days.
… I'm not sure if I should be proud or ashamed of this fact…
My rails product looks pretty good. The models all work, modulo a couple details that will start to come out in the wash; most of the controllers are up and running well, and many of the views work the way I want. I'm starting to transition to Backbone—normally, we would have been doing three-minute presentations of our progress today, but that's been pushed off to Monday, at which point instead of showing our Rails MVP we'll be showing our Backbone MVP.
Now that I remember how to rails, it'll be interesting to transition back to JS.
We were told about the Draper Gem pretty early on, and I didn't quite get it… I mean, I understand separation of concerns, but I didn't see the specific need for Draper.
I get it now.
I'm trying to take
gitvery seriously, which means that every time I wrap up some context, I'll try to stage it separately and commit just that portion of the project. I was joking with someone today that others' commit messages consist of "Monday", "Tuesday", etc. I've made 55 commits (according to github) in the past two days, which is something. party horn
So, what'd I do today? Well, there was a bit of yak shaving today, although admittedly not as much as yesterday—I'm making a lot of progress learning the details I need to know to accomplish what I want to do—but there's always more to learn. Some time around lunch, I broke down and started trying to hammer out as much as I could as quickly as possible, and damn the looks… for the most part.
So, in terms of physics, my position is way behind where it could be—I'm jealous of the guy who's got robust rspec unit tests running—my velocity is just about what it should be, and my acceleration is going really well. I think… I have a hard time perceiving the struggles of the people around me, and seeing which things I'm doing better than them, but every time someone transitions from Rails to Backbone I get a bit more self-conscious.
This seems to be a theme with me.
It's not that bad. Honestly, most of the pressure I'm feeling comes from the instructors. I know they mean well, and I know I should work faster and get over some of my hangups, but … I guess I'm overcoming my baggage in terms of how I attack problems. This is my problem and I'm personally invested in it, as opposed to some of the "toy" work we'd done, and I'm much more certain of the architecture and layout of all the tiny pieces. When I want to add something, I know which three files I need to tweak to make it happen (most of the time…), I open those windows, make those tweaks, commit, and am off to the races.
Contrast that with the general befuddlement I'd often experience when following along with some of the projects' specs. It's kind of nice.
Oh, I neglected to comment on my actual workflow. So, among the panes that I keep open are a small set of text files for "overall TODOs" (e.g. architecture and styling), for "upcoming TODOs", which are tasks that are a bit less ambitious than the first set but don't fit nicely into a smaller context (generally, I have 5-8 of these at a time), and then individual TODO: comments inside the source files. These last identify places where my code is broken but I can't do anything about it (I don't have the skills/time to fix it) or where there's an edge case that's known and I know how to address it, but it's not a priority at the moment.
This seems to be working pretty well for me, at least today. It certainly helps me shed the weight of tangential thoughts (helping me maintain focus on the matter at hand) and have a good place to go to feed me when I hit one of those transitional lulls.
They told us to try to finish our rails apps tonight. I got all my models composed, and have a lot of headway on my controllers; my views are sparse… and I need sleep. There's only so much that can be done in a day, although I could keep working.
We're all solo all the time from here on out.
Today was super interesting, and super… how to say it… introspective? Revealing? As mentioned, today was the beginning of two weeks of solo work on a single final project, and I spent a lot of time looking at myself, wondering, "what am I doing?"
An aside. We're working on CRUD projects—Create, Read, Update, Destroy—which describes in some way, shape, or form 90% of the web apps that people use. Sure, there are some flourishes, because the "things" in any given web page can be text, videos, votes, cats, whatever, but at the end of the day all that's being done is authentication followed by doing stuff to entries in a database and then serving content.
What makes CRUD apps interesting, then, is the content they provide and the interaction model they offer, as well as the way they integrate the data they have on hand. Stack overflow is a forum with sorting, at the end of the day, but there are layers on layers of customizations and social … stuff they enable that makes them the foremost place for responses to technical questions on the (English-speaking?) web.
Getting to that point is always hard. A lot of the web is still non-RESTful phpBB systems and so forth, whereas what we've been learning is slightly more advanced and much more responsive (not in the screen scaling sense) than the pre-AJAX web.
Today, however, was straight up phpBB-level work. Which made it … weird. It's one thing to be learning Rails for the first time and to know that you're not stopping there, but it's another thing entirely when you have to seriously examine a problem you want to solve knowing that it's just a waypoint on a long path. Needless to say, a lot of the romance has fallen off web technologies for me, now: everything seems pretty easy, in a way (despite my struggles to cover ground today, more on that later), and I'm much less impressed with most single-page apps, or even massive online presences. It all seems like "just" pushing bits around.
Sure, there's a lot to be said for impressive widgets, scaleability, and presentation, but my main bugbears on the modern web all come back to utility. When 90% of the single-page apps feel little more advanced than MS Word's outline view, what are people really doing? I think a new interaction model is due, but I don't know what it looks like. It will, of course, seem obvious in hindsight.
Back to the day, then. I know I was frittering away time, learning about advanced validations or how to be more succinct with Rails. Part of my introspection is realizing that I really do prefer small, focused tasks (bug hunting, making something tiny and super-polished) over architecting… but the model for this project is to cover as much ground as possible, showing off knowledge of many technologies and areas of study as possible. In a sense, breadth, not depth. I bet I could break any of our projects, two weeks from now, in ten minutes if not less—and that's just not the kind of problem solving I like. I'd rather make something tiny and robust than expansive and potentially brittle.
Am I missing the point of MVPs and Agile development?
Tomorrow, my goal will be to subsume my pickiness under the banner of covering ground - I will try to be picky over broader architectural issues. Does that even make sense? They're saying we should be working on Backbone by tomorrow, but I know I'll still be doing a lot of rails for much of the day.
Nonetheless, we pushed to heroku today, and … yeah. It's a bit ridiculous how sparse my app is, but that's life. It'll look better tomorrow, I swear.
Today's partner: Ben
Another Backbone day, another day thinking that I know enough about Backbone already only to realize there's a lot to know. Once again, the book they have assigned is a great resource, and really backbone (and rails, and some other technologies) deserve a full read-through in order to understand what they have to offer.
Maybe that will be one of my priorities in the new year.
- Get a job
- Actually read Backbone Annotated Source
But then again, talking around the water cooler, I keep hearing that other frameworks are much more …expressive? than Backbone. You'll always remember your first, but I shouldn't really pigeonhole myself as someone who's only willing to learn one framework… even though I haven't really learned it, yet.
In any case, it nice to get some depth. The topics feel much faster paced lately compared to Ruby/Rails, and I really am chomping at the bit to move on, but this time isn't being wasted. Especially not for the class as a whole—pair programming continues to yield educational benefits, due to cross pollination and so forth.
Our app today was a simple news reader. The coolest thing was using a gem, SimpleRSS, to pull live rss data from various sites around the web. I'm sure that we didn't do any more queries than any other random people during the day, but (for instance) while we were testing the reload button, I did feel a twinge of guilt for smacking their servers around lightly. It's weird to be using real data and not Yet Another Sample Set, because it's a reminder that we're not just messing around.
Hopefully the New Year finds a couple of us working on Real Problems™ with Real Data™… no matter what, we'll all be up to our ears learning for some time …
Today's partner: Cihangir
This morning started out with alternating stupid. John and I were both feeling lingering effects of the long weekend, and for the first hour or two before lunch we each had several moments of "wait, what are you doing there?" before we caught up with one another.
I'm glad to say that I remember more about Backbone than I thought, but it was still a bit humbling to realize just how fragile our knowledge is at this point. Way back at the beginning of the cycle, I remembered seeing requests for assistance pop up from the previous cycle's students in chat, and I thought that it was ridiculous that they, in their advanced state, would need TA help… I thought I was missing something.
What I was missing is that, while nine weeks in more than enough time to learn a lot of new things, we're not perfect nor are we professionals (yet). There are entire other languages and frameworks to be learned, knowledge to be solidified, skills to be polished… we've barely just begun. I feel like this cycle's schedule has been pretty perfect—we've had breaks when we needed time off, and the hardest assessments happened at times we were prepared for them. The silver lining to this most recent break, then, is the memento mori we all had coming back this morning: any time spent away from these skills reveals just how far we have yet to go.
I'm reminded of basic training. Everyone was so intent on getting any information that allowed them to pierce the veil of future uncertainty that we'd grill anyone who was as much as two weeks ahead to ascertain what lay ahead. In a new environment a tiny difference in starting point can make a huge difference in perceived knowledge, and we all kind of figured out that the career soldiers didn't have answers that would be relevant to us, yet. However, someone who just graduated basic, whose skills were fresh and memories raw and who could recall just how far they had come from civilianhood could provide much more useful information for us, the recently transitioned, than could anyone else.
The project today leveraged the anal retentive
I've seen a lot of programmers come out of four-year programs not knowing anything about style or consistency, and I suspect they drift into corporate codebases, uglifying things and driving their team into technical debt while ostensibly meeting their career goals… some, presumably, get the bug for style and consistency, but I fear that many do not.
There's really not much to say about the project today. It was another CRUD app—posts and titles, and a bit of dynamic rendering—but I feel a lot more comfortable with backbone's paradigms when it comes to generating and manipulating DOM elements, and handling client-side data manipulation. Tomorrow should be more of the same, as evidenced by the complete and total lack of readings, barring the project description itself… I think we're all chomping at the bit to get to final projects. We'll be hearing more about that tomorrow, god willing and the creek don't rise.
Today: solo day
So, we had the assessment today, which last cycle suggests was one of the hardest ones we'd be seeing, and it went alright. From Sunday where I was almost in tears in frustration at the authentication model, to today, where I was not only able to complete the assessment, getting all segments to pass individually on the third try (initial write, first debug, final run) while understanding what I was doing and not just writing things from memory, was huge. I know that others were faster, but for my own sanity I have to pretend that they were just coding from memory and not thinking about what they were doing. :)
We moved on to RailsLite, which was … interesting. These problems composed of partials are a nightmare to work through, though, because so much state that would be contained in a single file normally ends up instead fragmented across multiple files, and because I personally am not good at maintaining mass state like that, by the sixth partial I was lost. No part of the model itself was particularly difficult to grasp - we spent most of the day reading WEBrick documentation or Wikipedia articles and then writing one liners that didn't make much sense in isolation…
I can't say that this project was the best use of our time, but it was nice to gain some more understanding of how a HTTP request is handled in a dynamic manner. Writing a real Rails clone from spec/scratch might have been easier, albeit not a project for a single day. Oh well.