|
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?
|
# ¿ Aug 30, 2007 03:34 |
|
|
# ¿ May 3, 2024 19:37 |
|
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?
|
# ¿ Oct 31, 2007 04:13 |
|
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.
|
# ¿ Oct 31, 2007 07:36 |
|
floWenoL posted:For md5/sha1 assuming no malicious input? 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.
|
# ¿ Nov 1, 2007 07:22 |
|
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.
|
# ¿ Nov 11, 2007 08:26 |
|
Manage Rails Applications -> Configure startup mode
|
# ¿ Nov 14, 2007 07:24 |
|
|
# ¿ May 3, 2024 19:37 |
|
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.
|
# ¿ Nov 21, 2007 19:00 |