I wasn’t quite happy with my online store and was pleased to see a clean, open source store released. Andy Kim of Potion Factory released his store as open source. It’s Ruby on Rails, so it was a learning experience for me to get it running again. I learned a great deal in the 2+ days that I spent getting it running, but it is so much cleaner than my old stores. Hopefully I don’t have any problems with it as I just put the finishing touches on it this morning. It’s at store.receiptwallet.com. Things I learned from installing this on my server:
- Even though there is an RPM for mod_fcgid on Fedora Core 5 with Apache2, FastCGI still needs to be installed from the source
- The Apache configuration for FastCGI needs to have:
DefaultInitEnv RAILS_ENV production SetEnv RAILS_ENV production
in it. The first line for FastCGI to work and the second to work without FastCGI
- ruby-debug gem has to be installed to get the store to work in development mode and MUST be commented out to work under Apache
- To use multiple databases in RoR, the model has to look something like:
class User < ActiveRecord::Base require 'yaml' set_table_name "users" # we need to set this explicitly extra_coord = YAML.load(File.open(File.join(RAILS_ROOT,"config/database.yml"),"r"))["userdatabase"] self.establish_connection(extra_coord) end
(my pool of serial numbers is stored in a separate database and so are my users; I modified the store to interact with these other databases)
- On PayPal’s developer site, if you want to test Website Payments Pro, you need to use a Social Security Number of 111xxxxxx where x is any number, but this number can’t be used by another developer
- STDERR.puts is your friend. It’s great for logging stuff to the console
- RoR running under Apache must use FastCGI in a production environment or it is way too slow
- In application.rb, it MUST have:
class ApplicationController < ActionController::Base filter_parameter_logging "cc_number|cc_code|cc_month|cc_year" end
otherwise you have important stuff getting logged which is bad.
- Turn off IPN on PayPal or you’ll have an error when processing orders and people will order multiple times because they think it fails
That’s about it for now. I’ll update this as I remember more stuff so that I don’t waste time in the future and it may help others.
Thanks, Andy, for the store! While I don’t have a use for your products right now, I’ll be purchasing them anyway as your store is such an elegant solution, it is the least I can do to repay you.
Hmm, I’m not sure if my first comment made it. Here goes the second try.
Hi Scott! (trying to keep up the enthusiasm)
Congratulations on getting it to work. I know that it’s no easy task for a rails beginner.
One quick suggestion is that you can use log.debug and friends instead of STDERR.puts. For more details you can google up log4r, but basically you can use log.debug, log.info, log.warn and log.error.
Peace!
Thanks for the tip! I plan on ordering some Rails books and learning it so I can get a better understanding of how it really works.
Hey Scott,
I’m also new to Rails but I’ve read that using Proxying Requests is way better than FastCGI. You might want to research it a bit. There’s an extensive explanation of why this is in the book “Agile Web Development with Rails” 2nd edition at page 616.
I’m probably also going to use Andy’s store as soon as I get my new hosting from DreamHost. My current shared hosting plan doesn’t support Rails…
Hi Kenneth,
Thanks for the pointer; I have the Agile Web Development with Rails and Rails Recipes books on order, so I’ll take a look. (BTW, ordering the physical books through Amazon is only about $3 than ordering the PDFs, in case you like to touch books.)
Hey Scott,
I’ve also ordered the book, but I’m still waiting for it. So while I’m waiting, I use the PDF… But reading a book on your couch, away from the computer, truly is a whole different experience.
I got my new hosting with DreamHost up and running, but I’m having trouble getting the Potion Store running in local… D’you think you could give me a hand?