add to your Gemfile
gem 'rspec-rails'
end
Be sure to bundle install after changing your Gemfile
add to your Gemfile
Be sure to bundle install after changing your Gemfile
A bit today about setting up and debugging Capybara with truncated fixtures. Capybara comes with an array of choices for a driver, the thing that actually runs your tests. You can emulate a user using a real browser (Firefox or Sarari), or you can emulate a headless browser.
Today I'm going to be focusing on setting this up with Selenium to have Firefox run your tests.
Basic cheat sheet for me to help remember the new syntax of Rails 3. Check out the rubyonrails.org guide and also Rails 3 Upgrade Handbook
Here's a common pattern and good rails thing to know about: read_attribute(:symbol)
Basically what it does is read the attribute from the object's database field, even if you have over-ridden the name of that attribute with a virtual attribute of the same name.
When using Paperclip to save an attached image, how do I get & store the dimensions of the image? Best way is to create two fields to store the width & height and then just populate those fields when the image loads. (Other solutions, like reading it dynamically each, incur a lot of unnecessary disk activity.) Be sure to checkout some basic tutorials on Paperclip if you are unfamiliar with it generally. (see references below 1 2 3)
Step by step instructions.
1. create a new file at lib/paperclip_processors/thumbnail_with_dimensions.rb
2. Paste the contents of this gist into the newly created file:
http://gist.github.com/343678
This method was adapted from this blog post.
So, you are creating a thing (record) or maybe you are updating it. You've added created_by and updated_by fields to your model, and you've made these integers with the intention of them both being foreign keys to the Users model.
Maybe you've even setup a belongs_to relationsion to your User model like so:
The referrer is the URL the user came from. (It gets passed as part of the headers to the new request). You can get it out of rails this way:
Or the shorter version:
It seems that no one noticed that "referer" is actually not a word – the correct spelling is double-R ("referrer"). request.referer and request.referrer both work, but request.env['HTTP_REFERRER'] does not.
Note that when setting the Rails environment you have to pass it differently in different cases. For rake, set RAILS_ENV= as part of the command line options.
But when running script/console, you just put the environment name after the "script/console":
So you want to write a Facebook app written in Rails? Well, the good news is that it works. The bad news is that out of the box Facebook didn't quite design their platform to work with some of the core concepts (namely, REST) of Rails.
Quick cheet-sheet to help you remember when to type a singular entity or a plural.