|
Yeah, I'm using Geokit and the atrociously-named 'ym4r_gm' plugin to generate maps and markers and it's been easy.
|
# ? Oct 22, 2008 03:49 |
|
|
# ? May 14, 2024 20:37 |
|
I'm building a restful API but I'm not entirely sure how to go about writing functional tests for it. Currently I'm doing all my testing with curl, which is far from ideal. What I'd like to be able to do is something like: def test_should_create_user assert_difference 'User.count' do post :create, :user => { :username => 'fred' }, :format => :xml assert_xpath @response.body, "/user/username", "fred" end end Is this possible? I don't seem to get any response body back when I post with the format being xml. There's probably some obscure blog somewhere that details this, but so far I haven't found anything... edit: I was just browsing through the beast forum repository and they do some xml related stuff here: http://github.com/rubyonbr/beast/tree/master/test/functional/posts_controller_test.rb Is this still the recommend approach? jonnii fucked around with this message at 18:51 on Oct 22, 2008 |
# ? Oct 22, 2008 18:48 |
|
jonnii posted:I don't seem to get any response body back when I post with the format being xml.
|
# ? Oct 22, 2008 19:28 |
|
Bump because Rails 2.2 rc1 is out: http://weblog.rubyonrails.org/2008/10/24/rails-2-2-rc1-i18n-thread-safety-docs-etag-last-modified Improvements include: * Thread safety * ActiveRecord connection pool * Mailer layouts * Ruby 1.9 compatibility * Enhanced etag support * Internationalization * Full list of release notes To install: code:
And a bit of shameless self promotion if you want a pdf/video of what's new: http://envycasts.com/products/ruby-on-rails-22-package-deal
|
# ? Oct 25, 2008 05:14 |
|
drjrock_obgyn posted:Improvements include: Oh yay. Well it looks like the dispatching is threadsafe, but were they doing anything about ActiveRecord's threadsafety? I'm rusty on my multithreading but I seem to remember there being a few "big locks" in Rails.
|
# ? Oct 25, 2008 06:00 |
|
drjrock_obgyn posted:Bump because Rails 2.2 rc1 is out: Is this moving in the direction of parallel database access?
|
# ? Oct 25, 2008 06:33 |
|
Hammertime posted:Is this moving in the direction of parallel database access? Well, the connection pool now allows you to do concurrent connections assuming you have a non-blocking database driver such as neverblock. Pratik from the core team put up a good blog post explaining everything: http://m.onkey.org/2008/10/23/thread-safety-for-your-rails
|
# ? Oct 25, 2008 18:48 |
|
I just felt like popping in on this thread really quick. I have been programming in Ruby on Rails professionally since early 2005.
|
# ? Oct 30, 2008 01:37 |
|
Hi! Thanks for popping in.
hmm yes fucked around with this message at 05:29 on Oct 30, 2008 |
# ? Oct 30, 2008 05:27 |
|
I just felt like popping in on this thread really quick. Doo doop doouuu doo doo! Doo doo doo ooo doo!
|
# ? Oct 30, 2008 05:48 |
|
Rails programmers, I have a question: I have 2 tables, let's say Node(number: integer, owner: string) and Link(up: integer, down: integer) where up and down are foreign keys to Node's number. I really, really want to be able to go Node.find(x).up_nodes and get a list of Nodes back. Getting the Links back is obviously easy enough, but I can't figure out the right incantation for has_many :through and whatnot to get back a list of the Nodes themselves. Self-referential queries with non-standard keynames have defeated me
|
# ? Nov 7, 2008 05:23 |
|
dustgun posted:but I can't figure out the right incantation for has_many :through and whatnot to get back a list of the Nodes themselves. code:
|
# ? Nov 7, 2008 05:42 |
|
skidooer, (or anyone?) have you done much with couchdb since you posted about it way back when? I'm going to use it for my current project. couch potato looks cool. I like how it takes care of versioning, since you can't rely on the built in versioning if you want to keep it forever because when you compact you lose all the previous versions. But there are like a billion of other adaptors. You wrote your own right? I'm using merb, and I know datamapper has a couchdb adaptor, but using DM for couch seems wrong, since it's designed to solve sql problems. Maybe it's decent, I haven't tried it yet.
|
# ? Nov 7, 2008 10:10 |
|
skidooer posted:If I understand your problem correctly, you are looking for something like this:
|
# ? Nov 7, 2008 14:09 |
|
is there a good reason why ruby doesn't support the ++ or -- operators or is it literally just to piss me off?
|
# ? Nov 9, 2008 22:34 |
|
WHORENDOUS posted:is there a good reason why ruby doesn't support the ++ or -- operators or is it literally just to piss me off? I have no idea of an official answer, but after a year and a half, I've decided without any justification that it's for consistencies sake. a += 1 a += 2 vs. a++ a += 2 Edit: Pretty much just to piss you off.
|
# ? Nov 9, 2008 23:45 |
|
WHORENDOUS posted:is there a good reason why ruby doesn't support the ++ or -- operators or is it literally just to piss me off? Why do you need to increment something by one? It's so rare that I've ever had to do that in ruby, but I know there would be a few valid cases. I'm just making sure you're not writing while loop, or (god forbid) a for loop, when you have all the wonders of the enumerable mixin.
|
# ? Nov 10, 2008 00:35 |
|
Pardot posted:Why do you need to increment something by one? It's so rare that I've ever had to do that in ruby, but I know there would be a few valid cases. i use it to keep track of different events that occur inside of my loops. for the actual loop i think i invariably use .each edit: i do this mostly for debugging, still learning my way around the language and its 80 billion ways of doing any given task
|
# ? Nov 10, 2008 03:28 |
|
WHORENDOUS posted:i use it to keep track of different events that occur inside of my loops. for the actual loop i think i invariably use .each Have you tried using Netbeans to debug Ruby applications? It has full breakpoint and inspection features you'd expect, and will make debugging much easier then writing your own code to figure out what's going on.
|
# ? Nov 10, 2008 10:55 |
|
Thanks in advance for any advice you're able to offer. I've got a question: Has anyone had any luck getting RoR to run on Windows Vista using either Apache or IIS 7? I'm getting HTTP 500 errors accompanied by a FastCGI crash, and nothing in the logs indicates what is causing the problem. It looks like the requests are indeed being routed to my local Ruby installation, but nothing ever comes back except for errors. I've spent a couple evenings now trying every solution I could find via Google, to no avail. If anyone has any advice, I'd appreciate it greatly.
|
# ? Nov 18, 2008 08:04 |
|
MariusMcG posted:FastCGI You don't want to use fcgi. Either try passenger (if that works on windows??), or have apache proxy to mongrel. If you're just running one mongrer, you can just drop this in your .htaccess code:
If you're just doing this for development, don't even bother with apache or IIS, just go off the mongrel. If you're doing this for production, I have nothing but sympathy for you. It's going to be painful. It's probably easiest to use jruby and drop it in tomcat or glassfish. Also, whenever you install a gem, use --no-ri --no-rdoc because windows ruby is so goddamn slow.
|
# ? Nov 18, 2008 08:43 |
|
How is Passenger? I've got a couple of nginx+mongrel apps that are about to be moved to a new system and get some more development time, so if it's as good as it sounds then switching could be pretty easy.
|
# ? Nov 18, 2008 11:49 |
|
Sharrow posted:How is Passenger? I've got a couple of nginx+mongrel apps that are about to be moved to a new system and get some more development time, so if it's as good as it sounds then switching could be pretty easy. I've run it in light production for a while without issues. I never seemed to get the memory gains that ruby enterprise edition promises, but everything was nice and snappy. I still sit nginx out front of apache.
|
# ? Nov 18, 2008 14:04 |
|
In my limited experience, Passenger is definitely better than Mongrel, including being easier to manage, and faster. I'm updating a Rails 1.2.5 site; it used to use Mongrel and is now on Passenger and there's definitely a bit of a speed increase even on our dev/staging hardware. Pretty sure we have at least one or two production sites using it now too. Not to mention the fact that, at least where I work, they've had to constantly monitor the Mongrels with God or Monit because the Mongrels leak memory like a sieve and go down more often than a Saigon hooker Passenger seems free from both these problems (given that it's an Apache module, I'd hope so...) and is easier to set up, to boot. Amusingly the Django community's moving towards a Mongrel-esque platform (mod_wsgi) but I think it's probably more stable than Mongrel, otherwise it wouldn't be drawing people away from an entrenched Passenger-like situation (mod_python).
|
# ? Nov 18, 2008 14:44 |
|
Although I've said it before in this thread, I am going to give Passenger another post of support. It is easy to setup, seems to manage memory well, lets you track performance stats. After testing it out with a single production application I moved another 5 which had been running on mongrel over to Passenger. I also use Passenger for development, because the Passenger Preference Pane just makes setting up development environments nice and easy. Yeah, I know all I had to do before was edit hosts and create a new vhost. Meh
|
# ? Nov 18, 2008 16:24 |
|
I recently switched Forumwarz back from Phusion to a pack of Mongrels. Phusion seemed to perform more or less the same from a memory standpoint but I hated how I couldn't hot deploy safely. With a pack of Mongrels, you can do a rolling restart so that your app never goes down while pushing updates (since Nginx can proxy to the other mongrels.) With Phusion, your only choice is to touch the tmp/restart.txt, where it shuts down all processes and starts up again, preventing any requests from completing for up to 30 seconds. My users definitely noticed that!
|
# ? Nov 18, 2008 17:13 |
|
Pardot posted:If you're just doing this for development, don't even bother with apache or IIS, just go off the mongrel. That certainly makes sense, and thanks very much for the recommendation. I've been an amateur PHP developer for years, always working on a hosted server where I never had to worry about the web server; and my experience with RoR thus far has been educational about more than just Ruby or Rails. The Apache stuff has been frustrating, but also interesting and informative; and it's important to me to know not only how to get this working but also why the solution I adopt is the best one. With that said: After reading your very helpful post, I found this excellent article, which may be useful for anyone that wants to set up a Mongrel cluster or wants to know more about why it's a better solution than FastCGI in this case. I don't have any professional experience with this platform yet, so for the time being, any information I can find is immediately fascinating. Tonight I'll work on implementing your Mongrel suggestion, and will also take a look at Passenger. Thanks!
|
# ? Nov 19, 2008 01:40 |
|
Hey guys, I am working on my first Rails project and I've encountered a snag. I am working on a form for a model that has many models which in turn have many models. So I have like a one-to-many-to-many relationship (or a has_many :through). The only thing solution I can come up with is to number everything (http://pastie.org/318157) but this is neither convenient nor elegant. Anyone know a better way?
|
# ? Nov 19, 2008 03:01 |
|
Evil Trout posted:your only choice is to touch the tmp/restart.txt, where it shuts down all processes and starts up again, preventing any requests from completing for up to 30 seconds. My users definitely noticed that! What do you mean by "completing"? And I don't think I've ever seen an Apache reload or restart take longer than perhaps five seconds; are you saying it takes Passenger 30 seconds to actually spool up its Ruby processes?
|
# ? Nov 19, 2008 06:06 |
bitprophet posted:What do you mean by "completing"? And I don't think I've ever seen an Apache reload or restart take longer than perhaps five seconds; are you saying it takes Passenger 30 seconds to actually spool up its Ruby processes? Based on my experience, this is essentially accurate. It also takes about 30 seconds to hit a site after something like 2 minutes of no one accessing it. Phusion Passenger is absurdly slow and no amount of tinkering with the configuration seems to be able to ameliorate it.
|
|
# ? Nov 19, 2008 16:25 |
|
Panic! at the Fist Jab posted:Based on my experience, this is essentially accurate. It also takes about 30 seconds to hit a site after something like 2 minutes of no one accessing it. Phusion Passenger is absurdly slow and no amount of tinkering with the configuration seems to be able to ameliorate it. What kind of site are you running with it? The one I've been updating (which isn't terribly efficient either, and is Rails 1.2-based) loads pretty quickly after e.g. /etc/init.d/apache2 restart.
|
# ? Nov 19, 2008 19:07 |
|
Panic! at the Fist Jab posted:Based on my experience, this is essentially accurate. It also takes about 30 seconds to hit a site after something like 2 minutes of no one accessing it. Phusion Passenger is absurdly slow and no amount of tinkering with the configuration seems to be able to ameliorate it. There's something seriously wrong with your phusion deployment. I've had to benchmark phusion for a multi-app site (40 apps were used to test). Spool up time from scratch was always in the range of 2-5 seconds.
|
# ? Nov 20, 2008 00:07 |
|
I finally took the plunge and started teaching myself Rails a few days ago -- my dad wanted me to design him a simple website, and since I'm equally inexperienced in just about all webapp frameworks (except for Apple WebObjects, which I know better than I ever wanted to know ), I decided RoR was the one I wanted to pick up. I'm loving it so far, and I've been trying to immerse myself in "best practices" out of the box, and I'm now in a situation that's probably simple but I'm not sure exactly what's best to do here. I decided that I wanted to ERB-ify my stylesheets, so that I could use variable substitution for common color and size constants instead of repeating myself everywhere. Using some examples on the web, I cobbled together a StylesheetsController and routed it so that /stylesheets/*.css renders one of my /app/views/stylesheets/*.css.erb files, and that works. (It doesn't need to be anything RESTful that makes use of the model -- some examples showed how to incorporate user settings into the CSS, but I don't need that.) My question is, where's the best place to put those constants so that I can refer to them in my various .css.erb files? I don't want to define them just in a <% %> block at the top of the stylesheet since they're site-wide and should be used in multiple stylesheets (and, actually, I'd like to be able to refer to them elsewhere as well, say in JavaScript), and the opposite extreme of dumping them in environment.rb just "feels wrong" to me. Right now, I've dropped them into application_helper.rb and other *_helper.rb files as methods prefixed with css_* so they don't conflict with anything else in my app (I had to use methods because constants don't seem to get picked up properly), and that's working, but it seems like there should be a cleaner solution here. (Ruby 1.8.6, Rails 2.1.2)
|
# ? Nov 20, 2008 14:49 |
|
Flobbster posted:I finally took the plunge and started teaching myself Rails a few days ago -- my dad wanted me to design him a simple website, and since I'm equally inexperienced in just about all webapp frameworks (except for Apple WebObjects, which I know better than I ever wanted to know ), I decided RoR was the one I wanted to pick up. I'm loving it so far, and I've been trying to immerse myself in "best practices" out of the box, and I'm now in a situation that's probably simple but I'm not sure exactly what's best to do here. That's a pretty cool/crazy undertaking (in a good way). You've got a couple of choices I can think of: - YAML file that gets loaded in environment.rb and exists as a hash in the global name space - Database rows? Not as good as the yaml file really. - Lib files? Reasonable but loaded yaml is more elegant. Small note: make sure to turn on page caching for the stylesheets to ensure you get the best of both worlds, flexibility without the performance hit. The yaml loading can be achieved through something similar in your environment.rb file: code:
code:
code:
|
# ? Nov 20, 2008 15:07 |
|
Hammertime posted:Small note: make sure to turn on page caching for the stylesheets to ensure you get the best of both worlds, flexibility without the performance hit. Yeah, you'll want to cache the gently caress out of your CSS files. Make sure you compute them once, and once you deploy to production, make sure that nginx/apache or whatever is actually serving them. You don't want to hit your app to generate CSS on every request. You could also use something like Sass: http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html
|
# ? Nov 20, 2008 15:33 |
|
Flobbster posted:stylesheet stuff You might want to take a look at sass (http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html).
|
# ? Nov 20, 2008 15:35 |
|
jonnii posted:You might want to take a look at sass And while you're learning SASS, learn haml! Haml is the best.
|
# ? Nov 20, 2008 15:38 |
|
jonnii posted:You might want to take a look at sass (http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html). Thanks for this! I'd seen something about it briefly when I was searching for a solution to my problem, and I was initially reluctant to learn "yet another language", but it looks like this pretty much does exactly what I need without the effort of reinventing the wheel. Since none of my stylesheets actually need to be dynamic on the server -- I'm just using substitutions as a time-saving/bug-preventing measure -- then it looks like what I should do is just use Sass during development and then have a rake task generate the flat CSS for deployment. Then I don't have to deal with the caching issue at all. Pardot posted:And while you're learning SASS, learn haml! Haml is the best. One step at a time
|
# ? Nov 20, 2008 16:10 |
bitprophet posted:What kind of site are you running with it? The one I've been updating (which isn't terribly efficient either, and is Rails 1.2-based) loads pretty quickly after e.g. /etc/init.d/apache2 restart. Rack-based Sinatra. No more than 300 lines of code, and nothing to warrant the spool-up times that I was getting. I switched to Lighttpd proxying out to Thin and now site loading is near instantaneous.
|
|
# ? Nov 20, 2008 16:26 |
|
|
# ? May 14, 2024 20:37 |
|
Panic! at the Fist Jab posted:Rack-based Sinatra. No more than 300 lines of code, and nothing to warrant the spool-up times that I was getting. I switched to Lighttpd proxying out to Thin and now site loading is near instantaneous. Welp, my experiences (multiple production apps) and Hammertime's (???) would suggest your scenario was an aberration of some kind, although I don't know how different Sinatra is from Rails (i.e. perhaps there's some bizarre incompatibility that causes it to run poorly on Passenger).
|
# ? Nov 20, 2008 21:45 |