|
smug forum rear end in a top hat posted:association stupidity If anyone is curious, I ended up going with the following, and it seems to have been the right choice: code:
|
# ? Jul 14, 2011 01:56 |
|
|
# ? Apr 26, 2024 21:00 |
|
smug forum rear end in a top hat posted:If anyone is curious, I ended up going with the following, and it seems to have been the right choice Post your schema.rb file, please. I want to either congratulate you for knowing to add indicies on the join columns, or tell you to do that if you haven't.
|
# ? Jul 14, 2011 03:38 |
|
Pardot posted:I want to either congratulate you for knowing to add indicies on the join columns
|
# ? Jul 14, 2011 04:54 |
|
Pardot posted:Post your schema.rb file, please. I want to either congratulate you for knowing to add indicies on the join columns, or tell you to do that if you haven't. code:
|
# ? Jul 14, 2011 14:18 |
|
skidooer posted:Or congratulate Rails. It automatically adds indexes on join columns when you create your model. Wow, since when? I've been doing it in the migration file for years now.
|
# ? Jul 14, 2011 14:19 |
|
skidooer posted:Or congratulate Rails. It automatically adds indexes on join columns when you create your model. Is this new in 3.1 or something? I don't remember it happening on 3.0.8. I assume you have to use :references as your column type, but is there any other trickery needed? enki42 fucked around with this message at 14:22 on Jul 14, 2011 |
# ? Jul 14, 2011 14:19 |
|
Paperclip question: I have a model where I want the user to upload a file, then a resque worker does some things to the file and saves a finished version of the file. I want to keep both the original and finished files, so I think I need two paperclip fields. The question is, how to do I tell paperclip to create the finished file when I have the contents in a variable? I can only find info on how to create the file from a form submission. edit: Maybe it's OK to set the finished file's file_name then write to that file directly? Cock Democracy fucked around with this message at 16:44 on Jul 14, 2011 |
# ? Jul 14, 2011 16:05 |
|
enki42 posted:Is this new in 3.1 or something?
|
# ? Jul 14, 2011 16:18 |
|
So I have my models set up as sections => has_many pages and 2 sections have a boolean field called has_bio set to 1 where the rest are 0. Im trying to check the current page's parent section to see if the has_bio field is set to true. So why does this always evaluate as true? code:
|
# ? Jul 15, 2011 22:30 |
|
This is almost a cross-post from the SQL, thread, but how do you guys balance your hardware resources between your web and DB server? We're running Ruby with Apache/Passenger (should we look into nginx or something else?) My main question is should our web server have 12GB of vRAM, would it better used for our DB server? The server is has 3 vCPU's, Xeon L5520 @ 2.27GHz. The Ruby/Apache server has 5, and also has 12GB. Wouldn't it make more sense to give the DB server more RAM and maybe equal out the CPU's? Not sure if it's a single quad with HT enabled, or a dual-quad with HT disabled. Maybe we should enable HT and give each server 8 vCPU? Any tips on my.cnf settings for InnoDB? Going from this site: http://www.mysqlperformanceblog.com...b-memory-usage/ I've decided to change the following settings on our server. code: innodb_buffer_pool_size=8096M innodb_flush_method=O_DIRECT innodb_thread_concurrency=6 innodb_flush_log_at_trx_commit=2 innodb_log_buffer_size=4M cat /proc/meminfo on the server shows: MemTotal: 12299960 kB MemFree: 2467744 kB Our ibdata1 file is 16G
|
# ? Jul 15, 2011 23:50 |
|
Bob Morales posted:My main question is should our web server have 12GB of vRAM, would it better used for our DB server? If you can swing it, install Ganglia and see what sort of usage the app and DB servers have. It's not a hard and fast rule but CPU and disk speed are better on the DB machines, and depending, CPU and lots of RAM on the app servers. Obviously different circumstances can change that, but the best way to know for sure is to measure.
|
# ? Jul 17, 2011 01:01 |
|
Bob Morales posted:InnoDB? Is there a reason you're using mysql instead of postgres?
|
# ? Jul 17, 2011 01:17 |
|
Pardot posted:Is there a reason you're using mysql instead of postgres? No clue, I've only been here a few months. Their database originates back to when they were an ASP shop. I changed the DB stuff around this morning, don't notice any difference but I'll get a better idea on Monday since we're really only busy M-F 8am-8pm.
|
# ? Jul 17, 2011 01:40 |
|
Any of you fine folks doing something for the Rails 3.1 Hackfest next week?
|
# ? Jul 17, 2011 01:46 |
|
I really want to go to the one in Chicago but all the blog says is 'It is at Hashrocket!' and Hashrocket has no information posted
|
# ? Jul 17, 2011 02:42 |
|
I really want to go to the Toronto one but damned if I'm missing paintball day.
|
# ? Jul 17, 2011 06:33 |
|
Datamapper is pretty awesome guys; yes it involved switching my rails 3.x site from authlogic to devise, but that was minimal . No migrations, define properties once, auto migrate/upgrade... utterly awesome for development. Thought you should know! edit - plus, its faster and much nicer to use than AR.
|
# ? Jul 17, 2011 15:06 |
|
kalleth posted:Datamapper is pretty awesome guys; yes it involved switching my rails 3.x site from authlogic to devise, but that was minimal . No migrations, define properties once, auto migrate/upgrade... utterly awesome for development. Thought you should know! I spent almost a year working on a series of dating sites that used DataMapper, and let me tell you it was like pulling teeth. We had to make awful choices like sticking with a version that had known memory leaks or spending months upgrading to the latest version because they changed the API in huge awful ways. Also, the killer feature of DM at the time, the Identity Map, doesn't work when you go across multiple databases. If you find a bug in it, or have a question, good luck finding anyone to answer you. The IRC room would have 30 lurkers and nobody seemingly working on it or around at any time to answer questions.
|
# ? Jul 17, 2011 16:18 |
|
Evil Trout posted:I spent almost a year working on a series of dating sites that used DataMapper, and let me tell you it was like pulling teeth. We had to make awful choices like sticking with a version that had known memory leaks or spending months upgrading to the latest version because they changed the API in huge awful ways. Not my experience. The killer features of DM for me are only defining data model once (in the models) and proper o(x) scalability. Also, had issues moving AR to DM and theirc channel was more than helpful, providing that is you use Google and read docs first.
|
# ? Jul 17, 2011 16:53 |
|
kalleth posted:Not my experience. The killer features of DM for me are only defining data model once (in the models) and proper o(x) scalability. Also, had issues moving AR to DM and theirc channel was more than helpful, providing that is you use Google and read docs first. I think if you end up using DM for a large scale project you will change your tune. Auto-migrations are nice while developing a small site on your own machine, but completely impractical on a production system when you want to control exactly when migrations occur. For that almost everyone uses dm-migrations and then you are declaring data in more than one place. And the o(n) issue only really works on naive queries. And like I said it doesn't work at all if you have more than one database (such as in the really common master/slave build of mysql). Glad to hear they're around in IRC. I would just never trust a project that made such awful changes to backwards compatibility again. In one point version, calling bang methods (create!) would raise exceptions if the validations failed like rails. In the next release, calling the bang methods would avoid hooks. Completely different behaviour! We strongly suspected that we were the largest site in the world using DM as most people you hear championing it are working on weekend hack projects and don't have responses for these serious issues.
|
# ? Jul 17, 2011 17:59 |
|
kalleth posted:Not my experience. The killer features of DM for me are only defining data model once (in the models) and proper o(x) scalability. Also, had issues moving AR to DM and theirc channel was more than helpful, providing that is you use Google and read docs first. If these things are really what you're after then look at MongoDB and Mongoid.
|
# ? Jul 17, 2011 18:00 |
|
Been developing in Rails for a few months now and ran into some difficulties with this problem. I'm trying to customize the error messages which are displayed from the Model. I asked around on stackoverflow but couldn't get anywhere with the suggestions. Currently I verify that there are no duplicated Members when trying to create a new Member and add it to a Team. members_controller.rb code:
code:
Really appreciate any help I can get!
|
# ? Jul 17, 2011 19:04 |
|
Stup posted:Been developing in Rails for a few months now and ran into some difficulties with this problem. You're going to do one of two things here. The first is to pull the entire validation down to the model - preferred approach - using a custom validator (http://edgeguides.rubyonrails.org/active_record_validations_callbacks.html 6. Creating Custom Validation Methods) i.e. in the model code:
Alternatively, you can always do @model.errors.add_to_base in your controller, but I'd push the validation to the model...
|
# ? Jul 17, 2011 19:10 |
|
So in this case your :fieldname is an attribute of the team no? What if I'm using a Team method that is checking an attribute of the Member. Is there a way for this to check something that isn't a column in Team?
|
# ? Jul 17, 2011 19:45 |
|
Yes, there is; you'd use a custom validator with validates :validationmethod in the model. So, for examplecode:
|
# ? Jul 17, 2011 19:59 |
|
Doc Hawkins posted:Any of you fine folks doing something for the Rails 3.1 Hackfest next week?
|
# ? Jul 17, 2011 21:56 |
|
dustgun posted:I'm gearing up to upgrade my company's app to 3.1 anyways, so being able to really bug the hell out of core people when I run into any problems appeals to me. Deeply. Any idea if 3.1 is going to be dramatically different than 3.0? I'm in the same boat and just to see how bad things were I upgraded one of our 2.3.11 apps yesterday and it was oddly painless. I think I changed one or two lines of code but everything just worked. I was kind of expecting apocalyptic app failure across the board but it doesn't look like all that much changed in the core MVC parts of rails.
|
# ? Jul 17, 2011 22:48 |
|
kalleth posted:Yes, there is; you'd use a custom validator with validates :validationmethod in the model. So, for example This makes sense. I guess my Ruby isn't strong enough and I'm not quite sure how to build my conditional. Would you happen to know any good resources for me to read up on this?
|
# ? Jul 17, 2011 23:03 |
|
Stup posted:This makes sense. I guess my Ruby isn't strong enough and I'm not quite sure how to build my conditional. Would you happen to know any good resources for me to read up on this? Depends what you mean by 'conditional'. You mean your 'question'/'if statement' ? Most of the time when operating across a set your options are either each, map, or inject, depending on what the problem is.
|
# ? Jul 17, 2011 23:30 |
|
8ender posted:Any idea if 3.1 is going to be dramatically different than 3.0? I'm in the same boat and just to see how bad things were I upgraded one of our 2.3.11 apps yesterday and it was oddly painless. I think I changed one or two lines of code but everything just worked. I was kind of expecting apocalyptic app failure across the board but it doesn't look like all that much changed in the core MVC parts of rails. I've heard horror stories, but in direct experience, it seems surprisingly backwards-compatible. I guess my apps just weren't sophisticated enough to break.
|
# ? Jul 17, 2011 23:48 |
|
kalleth posted:Depends what you mean by 'conditional'. You mean your 'question'/'if statement' ? Most of the time when operating across a set your options are either each, map, or inject, depending on what the problem is. For example, I can't understand the syntax used here: code:
|
# ? Jul 18, 2011 00:00 |
|
Stup posted:For example, I can't understand the syntax used here: That's just a short way of doing a single-line loop in Ruby. It's the equivalent of doing code:
For example, for: array = [{:value => "one"}, {:value => "two"}] (an array of two hashes each with a :value element) code:
["one","two"] Which is identical to doing: code:
Best starting point for that kind of thing is the ruby Enumerable docs - http://www.ruby-doc.org/core/classes/Enumerable.html kalleth fucked around with this message at 00:21 on Jul 18, 2011 |
# ? Jul 18, 2011 00:19 |
|
Stup posted:For example, I can't understand the syntax used here: Give _why's poignant guide to ruby a read.
|
# ? Jul 18, 2011 00:36 |
|
Thanks for all your help! Off to do a little reading now.
|
# ? Jul 18, 2011 00:44 |
|
NotShadowStar posted:I really want to go to the one in Chicago but all the blog says is 'It is at Hashrocket!' and Hashrocket has no information posted http://hashrocket.com/contact-us Their office isn't super-big, but there's definitely room for maybe a dozen people there.
|
# ? Jul 18, 2011 01:21 |
|
Doc Hawkins posted:I've heard horror stories, but in direct experience, it seems surprisingly backwards-compatible. In general, you should avoid making apps sophisticated enough to break. Business logic stored in models is generally safe, calling model methods from your controllers is safe, view fuckery and diddling with load paths is not.
|
# ? Jul 18, 2011 01:22 |
|
Stup posted:Thanks for all your help! Off to do a little reading now. BTW you probably don't need a custom validator, For instance, you can just do code:
|
# ? Jul 18, 2011 06:44 |
|
kalleth posted:Ruby people like one-liners Better still is: code:
|
# ? Jul 18, 2011 15:04 |
|
8ender posted:I really want to go to the Toronto one but damned if I'm missing paintball day. If you do manage to come, say hi. I'm Ryan, I'm running the event.
|
# ? Jul 18, 2011 15:05 |
|
|
# ? Apr 26, 2024 21:00 |
|
enki42 posted:If you do manage to come, say hi. I'm Ryan, I'm running the event. drat, now I really wish I could come, especially since I have a developer here thats learning the ropes on Ruby and Rails after years of PHP and this would be some good experience. Unfortunately that developer is the owner of the farm we're all paintballing at. Its also a bit of a drive as we're all pretty far out in the countryside. Rural Ontario Ruby developers
|
# ? Jul 18, 2011 18:09 |