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
Argue
Sep 29, 2005

I represent the Philippines
Speaking of AJAX, is there some kind of way to retrieve an instance of a model as a javascript object? I mean, if you have a model called Book, and it has the fields title, description, ISBN, is there a function that will let me go myBook = theFunction(myBookId), such that I can say myBook.title, etc?

Adbot
ADBOT LOVES YOU

Argue
Sep 29, 2005

I represent the Philippines
I have a feature which lets a user make a mailing list, then send a notice to everyone telling them to take an online student survey. The mailing list consists only of email addresses, so what I figured on doing is assigning a unique (and unguessable) string to each invitation, so that I can tell which email address responded.

What's the best way to approach the string generation with Rails (using MySQL)? I'm assuming that I'll either be making some sort of sequence on the database, or I'll be keeping a counter, then salting and hashing it. Alternatively, is there a better way of tracking which students have responded short of requiring their own login?

Argue
Sep 29, 2005

I represent the Philippines

Anal Wink posted:

How about some sort of digest (md5 or sha2 or whatever) of their email address and some random salt you store with the address?

That'll work too; I'll probably be using that until I find a better solution. Ultimately, though, I'm worried about collisions, so I'm trying to find a more elegant solution.

I've found a module for Rails called usesguid, but it seems to only work on the primary key column, and based on the sample GUIDs, I think one could guess a GUID by incrementing a number or two.

Argue
Sep 29, 2005

I represent the Philippines

floWenoL posted:

For md5/sha1 assuming no malicious input? :psyduck:

I guess I'm being paranoid, but if the two of you are saying it's an acceptable solution, then I'll gladly stick with that; it's much easier to implement after all.

Argue
Sep 29, 2005

I represent the Philippines

copla posted:

How exactly are you supposed to open a file in public from model?

You don't want to do that. Not in the model, at least. The entire point of splitting your code into model, view, and controller is to keep your logic separate from your presentation. The public folder is for the web layer, so if you open files from public in your model, that means that when you modify the presentation layer, you'll have to worry about not accidentally screwing up the internals of the application.

Argue
Sep 29, 2005

I represent the Philippines
Manage Rails Applications -> Configure startup mode

Adbot
ADBOT LOVES YOU

Argue
Sep 29, 2005

I represent the Philippines
Shouldn't you just assign the id to the category_id property of Event? Or, you could do my_event.category = Category.find_by_id(the_id); I don't know which is the recommended way.

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