Saturday, February 7, 2009
Form Builder
I don't know why I never know about Form Builder! I was making my own form helpers but in the completely stupid way - in the helper files, which made it clunky. Check out these two posts that helped me out a lot. Although it can seem complicated because of all the (what I think is) meta programming, I suggest you just dive in and explore.
Friday, February 6, 2009
RPX Now: Single Sign-on
As I write this, I'm trying to install the single sign-on capability that RPX Now gives you on my Rails app. I've tried OpenID before (using open_id_authentication plugin and ruby-openid gem) and it was mightly complicated, plus you couldn't only use other 3rd party accounts.
RPX Now claims to be super easy and so far, with grosser's rpx_now gem, it almost seems too easy -- except there are no tutorials that I can find on Google. There are examples in gem's github site but they don't explain much.
This is my attempt at writing one.
First, install the gem (instructions in the github site). If you want to put it in your environment.rb file, it should look like this (remove or replace the version number with an updated one):
Check out actual responses (I just removed any personal data).
RPX Now claims to be super easy and so far, with grosser's rpx_now gem, it almost seems too easy -- except there are no tutorials that I can find on Google. There are examples in gem's github site but they don't explain much.
This is my attempt at writing one.
First, install the gem (instructions in the github site). If you want to put it in your environment.rb file, it should look like this (remove or replace the version number with an updated one):
config.gem "grosser-rpx_now", :lib => "rpx_now", :version => "0.3", :source => "http://gems.github.com"Then create an RpxController and add code similar to this to your user model. Of course, you don't have to process the data yourself, but I wanted to (thus my rpx_controller is a bit longer, and I had to read the response in the User model) so that if the rpx profile is missing anything, it will render a something like my normal login page that basically has a form_for(@user ...) where they can fill up the missing data.
Check out actual responses (I just removed any personal data).
Hosting Services
I don't run websites with thousands of users at a time, however, I thought I'd still announce what I use for my hosting services.
VPS: SilverRack
Good price, quick service. They don't spend time fussing over you though, but that's expected in a VPS.
Shared: HostingRails (disclaimer: affiliate link)
I've tried BlueHost, Dreamhost, but I've found HostingRails to be the easiest to deal with. Their support replies lightning fast, and don't diss you even if your problems are your fault!
VPS: SilverRack
Good price, quick service. They don't spend time fussing over you though, but that's expected in a VPS.
Shared: HostingRails (disclaimer: affiliate link)
I've tried BlueHost, Dreamhost, but I've found HostingRails to be the easiest to deal with. Their support replies lightning fast, and don't diss you even if your problems are your fault!
Tuesday, February 3, 2009
Using --trace; cucumber & machinist order of loading files
I followed this tutorial to easily use Cucumber with a fixture replacement plugin called Machinist. It worked great on my desktop, but when I moved to my laptop, running rake features didn't work - an "uninitialized constant Sham" error popped up and I spent a day figuring it out.
Although the context of this problem is Cucumber and Machinist (which includes Sham), this is a post that talks about using --trace when you run into problems similar to this.
IF YOU'RE FAMILIAR WITH CUCUMBER & MACHINIST...
The problem occured partially because I put my blueprints.rb file where env.rb is. I believe cucumber loads everything there in alphabetical order (doesn't explain why my desktop loaded things differently). The problem is that blueprints.rb tries to call "Sham" which is something that is loaded by Machinist, which in turn is loaded during or after env.rb, not before.
IF YOU'RE NOT FAMILIAR NEITHER CUCUMBER NOR MACHINIST...
The problem occured because of the order files were loaded. I do not know why files were loaded differently in my desktop vs the laptop, but what the heck -- I found the error by using --trace and actually read the big bad ugly code that rake conveniently hides from us.
http://pastie.org/379188
So the lesson is: actually read what --trace spits out! :)
Although the context of this problem is Cucumber and Machinist (which includes Sham), this is a post that talks about using --trace when you run into problems similar to this.
IF YOU'RE FAMILIAR WITH CUCUMBER & MACHINIST...
The problem occured partially because I put my blueprints.rb file where env.rb is. I believe cucumber loads everything there in alphabetical order (doesn't explain why my desktop loaded things differently). The problem is that blueprints.rb tries to call "Sham" which is something that is loaded by Machinist, which in turn is loaded during or after env.rb, not before.
IF YOU'RE NOT FAMILIAR NEITHER CUCUMBER NOR MACHINIST...
The problem occured because of the order files were loaded. I do not know why files were loaded differently in my desktop vs the laptop, but what the heck -- I found the error by using --trace and actually read the big bad ugly code that rake conveniently hides from us.
http://pastie.org/379188
So the lesson is: actually read what --trace spits out! :)
Friday, January 23, 2009
Speeding up emailing in tests
I lived with the fact that my test ground to a halt when my tests ran code that had to send emails. It finally got so bad I started asking around about it.
I knew about a method to test ActionMailer and not send out emails... and I thought: why not apply these to ActionMailer when it's in the test environment? I ran my tests with rspec. Check out the pastie to see the code.
I knew about a method to test ActionMailer and not send out emails... and I thought: why not apply these to ActionMailer when it's in the test environment? I ran my tests with rspec. Check out the pastie to see the code.
Tuesday, October 21, 2008
RSpec, attachment_fu
I've been looking for a solution to force RSpec tests to override the attachment_fu storage setting. Since I use s3, it was very inefficient when I'd run my tests because the assets would be saved in s3. Not only does it cost money, but it was very slow.
After spamming #rubyonrails I finally got an answer from _martinS_. He told me to do something like this: http://pastie.org/296895 - and it worked! I hope this helps you guys.
After spamming #rubyonrails I finally got an answer from _martinS_. He told me to do something like this: http://pastie.org/296895 - and it worked! I hope this helps you guys.
Sunday, September 28, 2008
Compiling Sphinx in Ubuntu
I had just watched Ryan Bates' screencast on Sphinx and I wanted to install it on Ubuntu. Took me a while to find out how, so here are my instructions. I'm on Ubuntu 8.04
1. Download the latest realease. It's 0.9.8 as of writing.
2. Install it with their instructions. I ran into a problem though - I have MySQL already but not the files Sphinx needs to install. If you ran into this problem, continue:
3. In console, type:
That will tell you the package you need to install.
4. Mine was libmysqlclient15-dev:
5. Try installing Sphinx again, it should work this time.
1. Download the latest realease. It's 0.9.8 as of writing.
2. Install it with their instructions. I ran into a problem though - I have MySQL already but not the files Sphinx needs to install. If you ran into this problem, continue:
3. In console, type:
mysql_config --cflags
That will tell you the package you need to install.
4. Mine was libmysqlclient15-dev:
sudo apt-get install libmysqlclient15-dev
5. Try installing Sphinx again, it should work this time.
Subscribe to:
Posts (Atom)