|
Colorblind Pilot posted:Second question that's sort of related: if you want a session to expire after 1 day, what's stopping the user from manipulating the cookie that stores the session hash to make it never expire? Since it seems like no session data is stored server-side, does your app really have no control over it? If I remember correctly, the cookie includes a signature, which is created using a secret that you define on the server side. If anything is changed about the cookie, the signatures won't match, and it will be considered invalid and the session ignored. This is incredibly important since if a user was able to change the cookie on their whim it opens you up to a whole host of attacks.
|
# ? Jul 2, 2010 01:08 |
|
|
# ? Jun 5, 2024 04:17 |
|
8ender posted:Just to be sure Apache + Passenger is the preferred setup for new Rails deployments right? Is it really as easy as just uploading the project files? There is a restart.txt that needs to be touched(modified) to let the server know it needs to reload your project. Otherwise yeah, it's that easy.
|
# ? Jul 3, 2010 15:46 |
|
In the application I'm working on before showing things like last names, email addresses, etc. I have it set up so that privacy settings are assessed that ensure a user actually wants their email address or last name to be visible. The problem is that often a whole unnecessary query that traverses backwards through the user model from within the privacy model is run: "self.user". Is there a way to magically give the user object into the privacy model when I reference the privacy object so it doesn't have to traverse backwards? Having trouble solving this logic experiment, or else there is something very simple I just don't see! code:
code:
|
# ? Jul 3, 2010 19:04 |
|
Nolgthorn posted:In the application I'm working on before showing things like last names, email addresses, etc. I have it set up so that privacy settings are assessed that ensure a user actually wants their email address or last name to be visible. The problem is that often a whole unnecessary query that traverses backwards through the user model from within the privacy model is run: "self.user". I had a similar issue once and I was able to do something like this (btw, you are using the self keyword way more than you should have to, it's usually unnecessary.) code:
|
# ? Jul 5, 2010 01:38 |
|
I've been trying to try out hobo but I'm gettting a lot of issues trying to connect to SQL. I'm sure I have something configured incorrectly or something is too new and is causing the problem. I literally can't get hobo to work at this stage.
|
# ? Jul 5, 2010 03:08 |
|
Nolgthorn posted:In the application I'm working on before showing things like last names, email addresses, etc. I have it set up so that privacy settings are assessed that ensure a user actually wants their email address or last name to be visible. The problem is that often a whole unnecessary query that traverses backwards through the user model from within the privacy model is run: "self.user". I think you may be looking for the :inverse_of functionality in ActiveRecord. See http://mediumexposure.com/better-memory-associations-inverseof/ for details, but it basically tells an association to avoid some unnecessary queries by assuming that if an association is the inverse of another association that it is safe to use the originating object if it has already been fetched from the database rather than trying to re-fetch it. To use it in your case, just modify your models thusly: code:
code:
This feature is completely undocumented in the Rails API documentation, so be wary of that. It is however mentioned very briefly in the ActiveRecord CHANGELOG, so one wonders why it has yet to be documented. There may be some bugs involving its use perhaps that have kept it from becoming a documented feature or something, but in any event I believe it will provide the solution you're seeking.
|
# ? Jul 5, 2010 04:09 |
|
Wow, thank you dark_panda. That is pretty much exactly what I was looking for, I can go back and clean up some of my code now. While Rails is using id columns to look up relational objects, the User object is exposed to my users through a different unique identifier. So the user objects weren't being retrieved by id most of the time, therefore are not getting cached. Is there a patch to make this whole inverse_of functionality on by default in the works currently? Is it memory expensive, too much bloat?
|
# ? Jul 5, 2010 19:16 |
|
Nolgthorn posted:Wow, thank you dark_panda. That is pretty much exactly what I was looking for, I can go back and clean up some of my code now. There's a ticket on the Rails Lighthouse with a patch for automatically figuring out inverse associations here: https://rails.lighthouseapp.com/projects/8994/tickets/3760-make-ar-guess-the-inverse-of-an-association-if-not-specified I doubt we'll see the patch merged into Rails 2.3.x for it any time soon, though, seeing as the feature itself hasn't been documented yet. The feature itself is a back-port from the Rails 3 branch, so it will be better supported in Rails 3. Since AR is going to be storing stuff in memory as it retrieves it from the database, if anything this would probably lead to less memory use, although you'd have to profile some requests to know for sure. I haven't gotten around to utilizing the feature yet myself so I haven't profiled anything, but I would imagine you'd see a performance improvement all things being equal given the savings in database queries and presumably some savings in object creation. Also, note that the feature itself was added in Rails 2.3.6 and isn't available at all before that version.
|
# ? Jul 5, 2010 23:36 |
|
There's some awesome new Enumberable methods in 1.9.2 http://rbjl.net/27-new-array-and-enumerable-methods-in-ruby-1-9-2-keep_if-chunk Enumerable — The Best Module™
|
# ? Jul 6, 2010 03:43 |
|
I'm having a little trouble planning out a few models with Activerecord. I need to setup something like this Company (has many) > Employees But some employees will also potentially have many other employees directly reporting to them and I need to track that. I thought of setting up a simple "Manager" model but the organizational structure can be vastly different from company to company. So it could look like this: Bob, Frank and Sally (report to) > Sam (reports to) > James and Dan (reports to) > Albert And I need to somehow keep track of these associations in a reasonable manner while also letting users add, remove and modify the employee associations. I'm stumped here and I really shouldn't be because I know how I'd do this with Java and some tables. I guess I'm a little too new to Rails to visualize how I'm going to pull this off properly with Activerecord. Any ideas? Edit: Oh for christ sakes this exact scenario is an example in the online (http://guides.rubyonrails.org/association_basics.htm)l Activerecord associations guide. 8ender fucked around with this message at 20:49 on Jul 6, 2010 |
# ? Jul 6, 2010 19:58 |
|
Pardot posted:There's some awesome new Enumberable methods in 1.9.2 http://rbjl.net/27-new-array-and-enumerable-methods-in-ruby-1-9-2-keep_if-chunk Yay for combinations/permutations... they are remarkably handy.
|
# ? Jul 6, 2010 22:38 |
|
Mr. Wynand posted:Yay for combinations/permutations... they are remarkably handy. That could be incredibly useful for some of the stuff I'm working on.
|
# ? Jul 6, 2010 23:09 |
|
Holy gently caress, the cyclical generators would have been really loving handy when I was learning abstract algebra for the first time. (I didn't know Python/list comprehensions at that time)
|
# ? Jul 7, 2010 01:33 |
|
Does anyone have any tricks for sanitizing and parsing international phone numbers that may be in no particular format? I've checked GitHub and Rubygems for libraries and the best one seems to be http://github.com/carr/phone, however, it still chokes with a lot of my data. Any recommendations that don't have me writing tons of custom regexe[s|n]?
|
# ? Jul 15, 2010 06:24 |
|
My boss wants me to create a Ruby mailer thats sent in variables from facebook via ajax but Ive never touched rails in my life. Anyone know of a good tutorial to get me though this?
|
# ? Jul 26, 2010 21:06 |
|
rugbert posted:My boss wants me to create a Ruby mailer thats sent in variables from facebook via ajax but Ive never touched rails in my life. Anyone know of a good tutorial to get me though this? Some good places to start: http://wiki.developers.facebook.com/index.php/User:Using_Ruby_on_Rails_with_Facebook_Platform http://guides.rubyonrails.org/action_mailer_basics.html and the absolute first place to start is learning Ruby: http://mislav.uniqpath.com/poignant-guide/
|
# ? Jul 26, 2010 22:04 |
|
Has anyone here worked with XMPP? I'm developing an application for a client that requires microblogging and eventually instant messaging. I definitely want to use XMPP for IM, and I am currently reading the book Professional XMPP Programming with JavaScript and jQuery and coming to realize that perhaps XMPP would be a great solution for the microblogging aspect as well, due to its near-real-time nature. I do have a few questions though... 1.) If you have worked with XMPP, what did you use it for? What problems did you encounter? How did you solve those problems? 2.) I already have a primitive "status update" microblogging thing going on right now for prototyping reasons, but it's all working off of one DB table...which I know is not going to be scalable in the future. I'd like to retain that RESTful design pattern, and still work off the User::StatusesController, but this Professional XMPP book got me real interested in Strophe handling all communication between jQuery/JS and the XMPP server. Can I have my cake and eat it too? 3.) How do I facilitate this communication? Do I get an XMPP server or something? I have the ability to set one up myself if so. CHRISTS FOR SALE fucked around with this message at 15:36 on Jul 28, 2010 |
# ? Jul 28, 2010 15:07 |
|
What would be the best way to have a one-off piece of data in the database? Things like a little blurb at the top of the main page or the content of an "about" page -- I'd like to be able to edit that kind of stuff from the page itself, so I don't want to hard code it into my views. But it also seems kind of silly and messy to create an entire model and controller for little stuff like that. Is there a recommended method for doing stuff like this?
|
# ? Aug 17, 2010 08:13 |
|
Gordon Cole posted:What would be the best way to have a one-off piece of data in the database? Things like a little blurb at the top of the main page or the content of an "about" page -- I'd like to be able to edit that kind of stuff from the page itself, so I don't want to hard code it into my views. But it also seems kind of silly and messy to create an entire model and controller for little stuff like that. Honestly ... I'd just create a simple model (pk id, string name and a blob/text for the content, plus an int version column could be useful) + controller. Using a rails model generator really doesn't take long "ruby script/generate model page_content name:string content:text version:int", and poke through "map.resources :page_content" in routes.rb. Wrap the displaying of the content in a 'cache' block so it hits memcache instead of the database for drawing the fragment and you're almost there.
|
# ? Aug 17, 2010 10:35 |
|
Hmm, alright. I wasn't sure if there was a simpler way of doing it or not. Thanks!
|
# ? Aug 17, 2010 21:41 |
|
Gordon Cole posted:Hmm, alright. I wasn't sure if there was a simpler way of doing it or not. I use high_voltage (http://github.com/thoughtbot/high_voltage) for my static pages.
|
# ? Aug 17, 2010 21:47 |
|
jonnii posted:I use high_voltage (http://github.com/thoughtbot/high_voltage) for my static pages. +1 for this. High voltage is awesome.
|
# ? Aug 18, 2010 17:34 |
|
Ooh, interesting. I'll give that a try, thanks!
|
# ? Aug 19, 2010 00:32 |
|
I'm having a hell of a time getting the sorting/filtering of results that I want. Basically I want to sort posts (ascending and descending) by title, date, author, and sections. The title/date/author are all columns in my post table, and section is a reference (section has_many :posts). I heard SearchLogic was good but it's not rails 3 ready and I'm developing on 3. I'm a few hours into trying to crank this out myself but I'm at wits end, are there any descent alternatives to SearchLogic that are Rails 3 ready?
|
# ? Aug 19, 2010 06:15 |
|
What's wrong with normal SQL ordering? Rails 3 query interface makes it really easy. http://edgeguides.rubyonrails.org/active_record_querying.html#ordering
|
# ? Aug 19, 2010 15:18 |
|
This is going to sound rather strange, but i'm bored and i fancy writing a rails app that some people will actually download and use. Anyone got any suggestions?
|
# ? Aug 20, 2010 20:43 |
|
NotShadowStar posted:What's wrong with normal SQL ordering? Rails 3 query interface makes it really easy. Pretty much. While in theory joining and sorting isn't always guaranteed when sorting a joined table, it works fine for the post->section structure you describe. I assume you're sorting by section name when you talk about sorting by section. Old school AR: code:
Otherwise, ActiveRecord has you covered, and it definitely has you covered for the situation you describe.
|
# ? Aug 21, 2010 00:38 |
|
EDIT: I'm an idiot. I had a column in my model named "Type". plasticbugs fucked around with this message at 04:15 on Aug 23, 2010 |
# ? Aug 23, 2010 04:03 |
|
plasticbugs posted:I had a column in my model named "Type". If its any consolation I've done that a bunch of times and each time it stops me dead for a while until I figure out what I did.
|
# ? Aug 23, 2010 06:31 |
|
plasticbugs posted:I had a column in my model named "Type". I've done this or similar a lot with Rails. One time it was a little obscure one and a problem didn't crop up with it until weeks later with some weird insane error on one specific specialized action. Now I use a thesaurus to pick most of my names. A couple of current favourites are: Crowd, Stream, Disclosure, Party, Participant, Actor, Candidate, Rival.
|
# ? Aug 25, 2010 21:21 |
|
code:
|
# ? Aug 25, 2010 21:28 |
|
Does anyone know of a good tutorial for installing Authlogic in Rails 3? I know how to generate the files and everything, I just keep getting errors. Has anyone here done this yet? for reference I followed: http://github.com/binarylogic/authlogic_example
|
# ? Aug 26, 2010 05:29 |
|
I believe the current rails 3 auth favourite is devise. http://github.com/plataformatec/devise
|
# ? Aug 26, 2010 06:55 |
|
Rails 3 released today Announcement
|
# ? Aug 30, 2010 03:34 |
|
Nolgthorn posted:I've done this or similar a lot with Rails. I'm going to start using your thesaurus trick. This wasn't my first run-in with a 'protected' word.
|
# ? Aug 30, 2010 20:59 |
|
Just rename the inheritance column to something that doesn't exist, it doesn't hurt AR at all. Although I do think that STI shouldn't be triggered unless you explicitly enable it on the model so that's never a problem in the first place.
|
# ? Aug 30, 2010 21:11 |
|
This may be off topic a bit. But I have been looking for an inexpensive host for rails applications. Most shared hosting providers seem to have a very poor Ruby support.. I played with heroku, and it's awesome for fast bug testing and showing off a Work In Progress to another person. I'd really like access to a low end cloud or virtual dedicated machine that gives me shell access so I can perform builds mess with config fikes and learn by breaking stuff. virtual machines are great because after i gently caress up my server it's easy to just re-provision. So... Anybody know of a cheap provider for a person trying to expend their Web Skills?
|
# ? Sep 1, 2010 00:54 |
|
kzin602 posted:This may be off topic a bit. But I have been looking for an inexpensive host for rails applications. Most shared hosting providers seem to have a very poor Ruby support.. linode.com has decent service. I recently switched to them from slicehost since the linode 512M slice is the same price as a 256M slice at slicehost. E: Or just use vmware or virtual PC locally with an ubuntu server install.
|
# ? Sep 1, 2010 01:05 |
|
What's wrong with Heroku for deployment and breaking poo poo on your own stuff?
|
# ? Sep 1, 2010 01:32 |
|
|
# ? Jun 5, 2024 04:17 |
|
Seriously heroku is the best: http://justuse.heroku.com/kzin602 (I also use them to hose my real site) Pardot fucked around with this message at 22:10 on Dec 8, 2013 |
# ? Sep 1, 2010 02:05 |