elfs: (Default)
[personal profile] elfs
I have long asserted that if you can't handle SQL or Javascript, you shouldn't be programming rails. And I don't mean a little bit; you ought to be able to eat, sleep, and breathe Javascript, HTML, CSS, SQL, and Ruby before you begin to sell yourself as a Rails programmer.

I am not a Rails programmer. Even so, I ought to be able to do simple things. Yet today I was stymied and went for my sledgehammer, the SQL statement.

Here's the layout: Stories exist. Stories belong to serials. Stories may optionally belong to arcs. Arcs theoretically belong to serials, but there is the "no arc" setting which, unfortunately, is global across the Journal Entries and my Other Stories archive, since there are plenty of standalone Journal Entries and most of the Other Stories stories are also standalone rather than complex. (That's a joke. Zoner will get it.)

So I wanted to be able to find all arcs that belong to a series. That's a simple statement in SQL: select distinct arcs.id, arcs.title, arcs.blurb from arcs, stories where stories.serial_id = 1 and arcs.id = stories.arc_id order by stories.pubdate. You see, arcs and serials only have a relationship through stories, not with each other.

There seems to be no clear way to do this in rails. It should be something like Arcs.find(...), but that didn't work at all.

This is on top of my discovering that yes, you can define your own pluralization rules, but you cannot override the ones inside Rails. "Series" will always be unpluralizable. If you try that, it works great until you trip over a call that dives beneath your application to the appserver layer, at which point Rails's internal pluralization rules take over and you're screwed.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 31st, 2025 02:31 pm
Powered by Dreamwidth Studios