paper_trail is an excellent gem to track record versions and changes.
You almost never want to reimplement something like it yourself. If you need to log some extra information, you can add them on top.
It comes with a really good README file that holds lots of examples. I'll show you only some of its features here:
- Setting up a model to track changes
- Just add
class User < ActiveRecord::Base has_paper_trail end
- Accessing a previous version
Updated the card with our current best practice (shared app code and specs via symlinks).
If you cannot install the gem 'RedCloth' via bundle install you might want to try the following.
Specifying extra build options for bundler which will only be applied when building RedCloth:
bundle config build.RedCloth --with-cflags=-w
If you get this:
Installing typhoeus (0.3.3) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /usr/bin/ruby1.8 extconf.rb checking for curl/curl.h in /opt/local/include,/opt/local/include/curl,/usr/include/curl,/usr/include,/usr/include/curl,/usr/local/include/curl... no need libcurl
You can fix it by installing the
sudo apt-get install libcurl3-dev
Now you should…
The following snippet demonstrates how you could create excel files (with spreadsheet gem) and format columns so that they follow a specific number format like currencies or dates do.
require 'rubygems' require 'spreadsheet' Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet :name => 'test' money_format = Spreadsheet::Format.new :number_format => "0.00 [$€-407]" date_format = Spreadsheet::Format.new :number_...
So you got this error, even though your Gemfile bundles
!!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)
The reason for this confusing error message is probably that your Gemfile says
mysql2, but your
database.yml still uses the
mysql adapter. Change it to use the
```raw development: adapter: mysql2 database: myproject_developm…
Today, I ran into trouble on a fairly fresh installed VM, running Ubuntu. I tried to
bundle install and got this stacktrace:
```text Fetching gem metadata from https://rubygems.org/.Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks! /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load – net/https (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from /usr/li...
- has_defaults is now a gem, no longer a plugin.
- The plugin version no longer exists. Note that plugins are no longer supported in 3.2.
- If you are working on an application that has the plugin version of
has_defaultsthere is no advantage to be gained from upgrading the gem. The gem is there for you should you one day upgrade to Rails 3.2+.
- Please don't use the defaults gem which we original forked away from in 2009. It sets defaults when a field is `bl…
After you configured your ODBC describe in
- Fix [RubyODBC]Cannot allocate SQLHENV when connecting to MSSQL 2005 with Ruby 1.8.7. on Ubuntu 10.10
- and Connecting to MSSQL with Ruby on Ubuntu - lambie.org
you can connect with
require "rubygems" require "se...
When trying to install the gherkin gem (possibly not a recent version), you might encounter an error saying:
cc1: warnings being treated as errors
If upgrading is not an option (corresponding issue on github), you can install it properly by changing the compiler flags as follows:
gem install gherkin -v '2.2.9' -- --with-cflags=-w
If you cannot install the specific version you intent to, try uninstalling the gem first.
To install the gem with bundler you can to do this:
Sometimes you want one distinct version of RubyGems to be installed to replicate the same behavior across multiple servers.
Usually would do this to update your RubyGems, but this always takes you to the latest version:
sudo gem update --system
While there are ways around the interwebs that use the
rubygems-update package and call its
setup.rb, there is an undocumented switch you can use:
sudo gem update --system 1.3.7
This updates to the given version, 1.3.7 in the above case, by walking the
rubygems-update package way it…
When you develop a gem and you have a
Gemfile in your project directory, you might be surprised that your gem dependencies aren't already required in your specs. Here is some info that should help you out:
- Bundler actually doesn't automatically require anything. You need to call
Bundler.require(:default, :your_custom_group1, ...)for that. The reason why you never had to write this line is that Rails does this for you when it boots the environment.
- That also means that if you have an embedded Rails app in your
specfolder (like [h…
You want to run a specific, maybe older version of bundler for whatever reason?
$ bundle _1.0.21_ -v Bundler version 1.0.21
Our awesome collection of rspec helpers (formerly known as "spec_candy.rb") is now available as a gem. It works, it is tested and there will be updates.
rspec_candy to your Gemfile.
require 'rspec_candy/helpers' to your spec_helper.rb, after the rspec requires.
List of features
Bundler 1.1 has been released. With this version you no longer need to wait for this:
Fetching source index…
The new Bundler is smarter and can fetch required metadata in a few seconds.
You can install the new version by saying:
sudo gem install bundler
Sometimes it might be helpful to have a version history for a gem, e.g. when you want to see if there is a newer Rails 2 version of your currently used gem.
The "Tags" tab at GitHub might be helpful as well.
Rack::Bug has been added to your project and your Apache2/Passenger only replies with an Error 500 (
Internal Server Error) you won't get any love from both application and Apache logs.
You can start a
script/server and try connecting there. It should also fail but you will most likely see this error:
Internal Server Error undefined method `new' for "Rack::Bug":String
While the following is (for some reason) working on OSX…
config.middleware.use "Rack::Bug", :secret_key => '...'
…you need to do this so it wor…