One of the models in a project I am working on right now ends in ‘status’. Rails handles that just find but in my tests I started noticing an odd error: test: Lookup should belong_to lookup_status. (LookupTest): NameError: uninitialized constant LookupStatu </pre> The Shoulda test looks like this: should_belong_to :lookup_status </pre> Nothing to complicated there….
Tag: Ruby On Rails
Tip for Testing Email with Ruby on Rails and Shoulda
Shoulda comes with a great method for testing email called ‘assert_sent_email’. (If you try it and get a method missing error update Shoulda. Not that anyone wouldn’t know to just do that). No matter what you use to test email as long as you are in test mode your emails will be placed into an…
Shoulda, assert_sent_email and Unreal Users
I have been banging my head against a problem in my testing. Using the UI everything worked as expected, but my tests were failing when I tried to see if emails were being sent in a specific case. Here’s the test I was trying to run using Shoulda: context “reset password for user that has…
ActiveSalesforce and Ruby on Rails > 2.1
We have to do an integration with Saleforce for a Rails project we are working on. I keep getting this error: The :dependent option expects either :destroy or :delete (:nullify) I posted to the Salesforce forums and didn’t get any response so I did some more investigation. Turns out there is a bug and a…
Checkbox list in Ruby on Rails using HABTM
Checkboxes are one of those things that look easy and should be easy, but they aren’t always easy. I needed a solution that could create a checkbox list of languages that a user speaks. So I don’t forget here’s how to do it: The migrations are important. You have to be sure to exclude the…
51Weeks at ICLS
Last year for our open ed conference here at Utah State I built an application called 51weeks to help preserve the presentations and to help people interact. Tomorrow it will be used at ICLS in the Netherlands. The hardest part about these kinds of applications is life cycle management. I am frequently asked to build…
Ruby on Rails – render :action doesn’t run action
I want to be cool like everyone else so I use a REST methodology for most of my Rails controllers these days. I wasn’t ever quite sure how my views managed to maintain values for a given object (User, Post, etc) after a failed call to create that that did a render :action => new….
Ajax calls using jQuery in Ruby on Rails
jQuery is the hot javascript library and it is small and it is cooler than Prototype, the default library that comes with Ruby on Rails. Ergo I plugged it in and pulled out everything else. The ajax calls are very simple and look like this: $.post(“function_name”,{ key:value } ,function(data) { // do stuff with data…
Dump an Existing Database Schema Into a Ruby On Rails Migration Ready Format
I have been looking around for a plugin or bit of code that can dump the schema from an existing database into the Ruby on Rails database migration format. The solution is a ‘duh’ moment, and probably obvious to most Rails programmers. All you have to do is change your database.yml file so that it…
Elastic Cloud Computing
One of the most difficult tasks when putting up a new site is picking the right host. Moving hosts later on is terribly difficult so choosing the correct hosting company is as important as selecting a business partner. I’ve collected about 30 hosting companies in my delicious bookmarks. Some are specific to a platform others…