Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
luminalflux
May 27, 2005



I'm starting out with a project in Rails, and have a couple questions:

- Why doesn't references in create_table in my migration create a foreign key? Why do I have to run a "execute 'ALTER TABLE ...'? I thought the whole point of Rails was to not repeat myself.

- Why doesn't acts_as_list automatically add 'ORDER BY position' clause when calling Foo.find(:all)? I've said it's a list with a position column, why do I have to specify this again in my controller?

- How do I create functions like 'edit_thingies_path' used in link_to in my view for other controller methods? I spent a 3 hour train ride trying to figure this out but all I got were stack traces and I reverted to specifying the action and arguments manually.

Adbot
ADBOT LOVES YOU

luminalflux
May 27, 2005



wunderbread384 posted:

The Rails folks don't believe in foreign keys so you probably won't ever see support for them in core. It's stupid, but one of the many downsides to Rails being "opinionated software" is when their opinion is wrong.

Is it just me or is there a huge "don't trust the database" vibe coming from the Rails camp?

luminalflux
May 27, 2005



wunderbread384 posted:

There's a bunch of plugins you can get that will do it, though, try Foreign Key Migrations.

1500 rows of code that can't automatically figure out that my primary key columns aren't named "id", even though the primary keys are specified in the schema, migrations and models. Quality code right there.

Yes, I should probably just let my database be a stupid object store, but a lot of habits (foreign keys, naming primary keys to make joins easier) are hard to shake.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply