|
atastypie posted:Hobo is brand new, so there is very little up to date documentation let alone an entire book. You could print off the docs from the website and reference those instead. Out of curiosity, why are you using habtm instead of has_many in this situation? This looks like an instance where an author should have many books and a book belong to an author. Your domain may be a bit different though. Anyway, you should just be able to do the following: author = Author.find(:first) price = author.books.sum(:price) However, you would want to do something like this: Models: code:
code:
Not sure what reasons you have for making price an integer, but it could be a decimal column as well. See http://pragdave.pragprog.com/pragdave/2006/07/decimal_support.html.
|
# ¿ Aug 24, 2007 07:57 |
|
|
# ¿ Apr 25, 2024 22:35 |
|
shopvac4christ posted:What I'm trying to say is, why can't we have something along the lines of a deployments directory, that has deploy.rb's and subdirectories for all the applications we can deploy, which is completely unrelated to any local checked out copies of the source? This is true and you don't technically need to follow the way capistrano does things. It would really help if you did, though, because cap is opinionated (but configurable) software. Given your example, I'm not sure I see the benefit in having ~/Deployments/MyApp1/deploy.rb vs ~/Apps/MyApp1/config/deploy.rb. You've traded having a deployments directory for having a directory with access to the source code. Also, you may want to have custom recipes which may be easier to remember why the functions do what they do if they're right there in the app. Also, since is the RoR love in thread, I just started a RoR news podcast. Shameless self promotion at http://www.railsenvy.com/podcast.
|
# ¿ Oct 3, 2007 07:40 |
|
Anal Wink posted:I've used acts_as_solr before. What's the difference between ferret ad acts_as_solr? They both use lucene if I'm not mistaken. Ferret is lucene written in ruby, solr is written in Java. I'd say to stick with solr or sphinx for full text search. Funny story about that. I was at the Rails Edge conference sitting next to Ezra and asked him what he thought of Ferret. He said it was great for development but once you get to more traffic it tends to buckle. Fifteen minutes later I get an emergency "our site is down" email from the clients for whom I just deployed a ferret based solution. I've heard a bunch of reports about people deploying ferret, though, so take that with a grain of salt.
|
# ¿ Jan 10, 2008 22:00 |
|
savetheclocktower posted:Seconding Slicehost. I just moved from shared hosting to a 256MB slice and the process was ridiculously smooth. A VPS has more of a learning curve than shared hosting, since you're now in charge of everything, but I credit Slicehost's exhaustive library of HOWTOs for easing that transition. I don't run Rails apps on mine, but many others in the Slicehost community do, and they appear to love it. Thirding Slicehost. They are the best for Rails apps unless you go with Rails Machine or Engineyard, which are both *extremely* pricey. Do not go with Media Temple for a Rails app -- you will hate life. I've had poor experience with their dv for a client and a friend of mine is in the process of moving his gs to a different host, probably slicehost.
|
# ¿ Jan 14, 2008 06:03 |
|
Nolgthorn posted:Help!
|
# ¿ Feb 5, 2008 07:23 |
|
Plastic Jesus posted:Is there an easy way to find out in irb which method is faster in these situations? I'd like to know that the performance difference is for regex v. unpack v. anything else. And while we're on the subject, does Ruby use the old-style (and much faster) Bell Labs DFA regex algorithm or the weird (and slower) perl-style algorithm? code:
code:
|
# ¿ Jul 20, 2008 10:45 |
|
atastypie posted:Jumping in to say that if you haven't tried out Passenger/mod_rails... give it a go. It's pretty awesome: just create your vhost file for the application and everything works from there. No setting up mongrel clusters, no extra configuration, easily stop/start, no PID problems. Pretty straightforward to setup cap tasks of your own to do things like restart the application or disable a vhost. Just wanted to +1 that. Also if you're on OS X check out the Passenger pref pane: http://www.fngtps.com/2008/06/putting-the-pane-back-into-deployment to add it right in to system preferences.
|
# ¿ Aug 2, 2008 06:49 |
|
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 |
|
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 |
|
jonnii posted:I think I found about it from the rails envy podcast. Now I answer all gem related questions on stackoverflow with RVM propaganda in the hope that it gets more traction. I found out about it from the internet. But seriously I found out about it from http://delicious.com/popular/ruby -- I have it set up in RSS menu.
|
# ¿ Feb 4, 2010 00:27 |
|
Nolgthorn posted:This is because the name field is used to render the model object as a parameter in my model. But I don't really know how to fix it. The best thing would be if I could pick and choose times that to_param renders as the name, or renders as a id. It doesn't feel too railsy but I've done that in the past by doing page_path(@page.id) for occasions where it needs the id and letting to_param take over in the instances where it doesn't.
|
# ¿ Apr 4, 2010 20:25 |
|
Not a joke: Would any goons be interested in helping create a blog engine using rails 3 with a mongodb backend? I hesitate to say that the world needs another blogging engine but rails sure does. I really don't like any of the existing ones.
|
# ¿ Apr 7, 2010 06:55 |
|
I wanted to post this because I figured it out the other day and it's pretty cool. I've been using rvm for development lately and different gemsets for each project. It gets to be cumbersome to switch gemsets and versions each time you go in to a project. Rvm supports config files in the form of .rvmrc per project and can be set to automatically change ruby versions. The syntax is as follows:code:
|
# ¿ May 15, 2010 16:20 |
|
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 |
|
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 |
|
To everyone asking about servers and managed hosting, I highly recommend moonshine: http://github.com/railsmachine/moonshine for managing your own servers. It's really easy to install and configure everything and if you're using a vps you can always roll back pretty easily.
|
# ¿ Sep 16, 2010 18:12 |
|
rugbert posted:I was taught to use type so that I could have inherited models. So I have a PageContent model and then I have a BlogPost model inheriting from it and I needed to have they type field to make it work. Which is does, but in this case I want to reject all BlogPost entries. Try doing the equivalent query that Hammertime suggested but with rails 3 syntax: code:
code:
|
# ¿ Jan 17, 2011 06:50 |
|
|
# ¿ Apr 25, 2024 22:35 |
|
rugbert posted:Oh cool thanks. That did it. You're telling paperclip to use the options for local storage there so it's probably not getting symlinked on each deploy (which you don't want to use with Heroku anyway). Have a look at the rdoc for the s3 storage and adjust the parameters accordingly: http://rdoc.info/github/thoughtbot/paperclip/master/Paperclip/Storage/S3.
|
# ¿ Jan 18, 2011 06:53 |