I am new to Ruby and Rails so this question might be trivial, but
How can you include/use a gem in Rails?
Do you just put "gem '
What do you do after that?
If this procedure is correct, when I try to run 'rails server' it spits out this error
/.rvm/gems/ruby-1.9.2-p0@global/gems/gdata-1.1.1/lib/gdata.rb:21:in `require': no such file to load -- jcode (LoadError)
What am I doing wrong?
Ruby 1.9.2 Rails 3 RubyGem 1.3.7 Gem i'm trying to use 'contacts' 1.2.4
Thanks guys, Sean Chan
The best authentication gem If you are building a Rails API, then you will probably need token-based authentication and that is when Devise Token Auth comes in. This gem is built on top of Devise, one of the most popular authentication gems for Rails which you may have already worked with.
Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity. It encourages beautiful code by favoring convention over configuration.
If you are building a Rails API, then you will probably need token-based authentication and that is when Devise Token Auth comes in. This gem is built on top of Devise, one of the most popular authentication gems for Rails which you may have already worked with. If that’s the case, then you’ll get familiar with Devise Token Auth very easily.
Another gem that we find very useful for factories is Faker, as it provides an easy way to generate fake data. Last but not least, if your API relies on third party services you will need stubbing on the external HTTP requests and for this I recommend using Webmock.
I had the same issue, here is how I fixed it:
In case you havent already, put gem 'contacts'
in your Gemfile
and run
bundle install
Ruby >= 1.9 doesn't have jcode, a module to handle japanese (EUC/SJIS) strings, as it supports unicode natively.
So you will need to add: require 'jcode' if RUBY_VERSION < '1.9'
to your gdata gem
found under your .rvm
directory somewhere similar to this:
/home/.rvm/gems/ruby-1.9.2-p0@your_gemset_name/gems/gdata-1.1.1/lib/gdata.rb
change line 21
to:
if RUBY_VERSION < '1.9'
require 'jcode'
$KCODE = 'UTF8'
end
As I'm also a noob how would I go about letting the author of the gdata gem know about this?
To use a Gem in Rails 3 you need to specify it in the Gemfile
and use bundler to install the dependency. Here's a few resources to learn more about Bundler and Rails 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With