thoughtbot / paperclip Gem installation - ruby-on-rails-3

Im not going to start by saying i'm a newbie etc. Jokes, been learning Rails for nearly month using Lynda.com. I use Mac, Mac OS X Lion 10.7.
I am trying to intall Paperclip Gem but i can't seem to figure out what i'm doing wrong.
I followed the instructions on https://github.com/thoughtbot/paperclip/wiki/Installation
I added this line to my config/environment.rb
config.gem 'paperclip', :source => 'http://rubygems.org'
and i then tried to run
rake gems:install
I get an error message:
(in /Users/fred/Ruby/food)
rake aborted!
undefined local variable or method `config' for main:Object
/Users/fred/Ruby/food/Rakefile:4:in `require'
(See full trace by running task with --trace)
I then tried the following as an alternative when the above failed
script/plugin install git://github.com/thoughtbot/paperclip
I get the following error
-bash: script/plugin: No such file or directory
My question is how do install this gem? I have read a lot of other posts that say i should include gem 'paperclip', "~> 2.3" is this the same as what i did above?

Best to use bundler. Steps are
Install bundler: gem install bundler
Add to Gemfile: config.gem 'paperclip'
cd to where the Gemfile is and run: bundle install. This will install all the gems mentioned in the Gemfile
Ps. I assume that you are not using rvm. Also, you may need to prefix sudo to the command in step 1 above in case the command does not work for you due to a permission problem.

Related

Rails can't install gem sqlite

Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/gem_make.out
An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.0' succeeds before bundling.
I tried to install earlier version on sqlite, not working.
Tried one of the solutions from stackoverflow :
gem 'sqlite3', '~> 1.3.6'
getting this error
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command sqlite3,
Please help i'm new in Rails , this is my first project in rails.
Add gem 'sqlite3' to Gemfile in the root directory of your rails project. Then run bundle install and it should install sqlite and make it available to use in your rails project.
Specify git and branch for the gem sqlite3 in your Gemfile should fix the problem.
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
For more info
https://medium.com/#declancronje/installing-and-troubleshooting-ruby-on-rails-sqlite3-windows-10-fix-87c8886d03b
cannot load such file — sqlite3/sqlite3_native (LoadError) Ruby on Rails
Replace gem 'sqlite3' with gem 'sqlite3', '~> 1.3.11' which is in Gemfile in the root directory of your rails project. Then run bundle install.

gem not working after installing 'thin' - rails 3.2.8

I got stuck in a dead end after trying to install the gem 'thin' on the environment
RHEL 6.0
Ruby 1.9.3
Rails 3.2.8
As indicated, I added
gem 'thin'
to my Gemfile and ran
bundle install
The installation seemed to be successful, but after that, whenever I run 'gem', I get
<internal:prelude>:8:in `lock': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
deadlock; recursive locking
Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.3 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/extensions/x86_64-linux/1.9.1-static/eventmachine-1.0.3/gem_make.out
While if I run again 'bundle install' I get
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at
http://bit.ly/bundler-issues. Thanks!
<internal:prelude>:8:in `lock': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
deadlock; recursive locking
Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.3 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/extensions/x86_64-linux/1.9.1-static/eventmachine-1.0.3/gem_make.out
I even tried to follow troubleshooting at https://github.com/bundler/bundler/blob/master/ISSUES.md but nothing has changed.
Looks like there's something corrupted in the eventmachine gem installation, but I can't neither uninstall or reinstall it.
Has anybody got an idea?
I would like at least to be able to revert to the (working) configuration prior to thin installation....

Trying to debug ruby 1.9.3p194 rails 3.2.7

Arg, looks like this is a fairly common problem but I can't seem to figure out how to get my debugger working. I've installed a myriad of gems to try to get this bad boy running but no luck. Here is a list for completeness. I've included my gemfile as well. As is probably quite obvious I'm a RoR newb. I'm using RubyMine as my IDE and upon trying to debug I get an error that states "The gem ruby-debug-base19x required by the debugger is not currently installed. Would you like to install it?". Of course, upon saying 'yes' to download the mirror is broken and the download fails resulting in the following error:
5:56:46 PM Error running Development: SponsorBid: Cannot start
debugger. Gem 'ruby-debug-ide' isn't installed or its executable
script 'rdebug-ide' doesn't exist.
Even though this question duplicates two other questions here, I'll answer it for the sake of completeness.
In order to debug from RubyMine you must use only 2 debug gems:
ruby-debug-base19x
ruby-debug-ide
Exactly these gems must be used, not ruby-debug-base19, not ruby-debug19, not debugger . All the other debug gems must be uninstalled and removed from the Gemfile.
See this answer for the details how to install proper debug gem versions. If you have a problem downloading linecache19-0.5.13.gem gem, try this mirror instead.
Verify with gem list that you have the following or more recent versions installed:
ruby-debug-base19x (0.11.30.pre10)
ruby-debug-ide (0.4.17.beta9)
No other debug gems should be listed by this command.
As stated in another answer, debugger gem must not be used, it will conflict with the debug gems used by RubyMine and debugger will not work. You must uninstall this gem, remove it from the Gemfile and ensure that your code doesn't call any methods from this gem and is not trying to load it.
Happy debugging!
As suggested by #Anjan, your Gemfile for debugging can look like this:
gem 'linecache19', '>= 0.5.13', :git => 'https://github.com/robmathews/linecache19-0.5.13.git'
gem 'ruby-debug-base19x', '>= 0.11.30.pre10'
gem 'ruby-debug-ide', '>= 0.4.17.beta14'`
Just run bundle install to get the proper versions of the required debug gems.
This is what I used in my Gemfile to install the required gems through bundler:
gem 'linecache19', '>= 0.5.13', :git => 'https://github.com/robmathews/linecache19-0.5.13.git'
gem 'ruby-debug-base19x', '>= 0.11.30.pre10'
gem 'ruby-debug-ide', '>= 0.4.17.beta14'`
No manual gem installation required and will automatically work on your fellow developers' computers.

Heroku error when launch rails3.1 app missing postgres gem

I am trying to deploy to heroku.
Rails 3.1.0.rc4,
I get the following error from Heroku logs:
Starting process with command: `thin -p 48902 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-20T11:25:44+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) (RuntimeError)
I tried to install the activerecord-postgresql-adapter but then I get this error:
Could not find gem 'activerecord-postgresql-adapter (>= 0)' in any of the gem sources listed in your Gemfile.
So I tried to add this to my gem file
gem 'pg'
which produced this error:
Installing pg (0.11.0) with native extensions /Users/imac/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
any ideas?
You don't have to install Postgres locally. In your Gemfile, put 'pg' in group :production, as johnny-grass suggests, and then when you run bundle, just specify --without production, like this:
bundle --without production
Unfortunately, you have to remember this argument when you run bundler, but at least you don't have to install and maintain postgres locally.
Please note that Heroku "strongly recommends against" using sqlite, saying that "Your production and development environment should be as close to identical as possible" http://devcenter.heroku.com/articles/rails3
Do you have PostgreSQL installed on your computer? If you don't then install it first, then install the pg gem.
# gemfile
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3' # you will need this too
gem 'pg'
end
I found a solution in this Heroku article.
As Jared said, they suggest to create a different group for postgresql.

ruby on rails gem error - No such file to load

I am trying to use the koala gem per these instructions: https://github.com/arsduo/koala/wiki
I did a gem install koala. I see the gem in the list of installed gems.
The instructions say to add
require 'rubygems'
require 'koala'
It doesn't say where. I tried it to add the lines to the beginning of one of my controllers.
Then I also tried it in the initializer file:
C:\Documents and Settings\mtariq\blog\config\initializers\koala.rb
I always get the same error:
no such file to load -- koala
I installed the gem.. so what 'file' is it trying to load?
Any help would be appreciated. I know I must be doing something stupid but can't find any clues.
Mariam
Assuming you are running rails 3, just add the koala gem to your Gemfile, then run 'bundle install'. No need to require any library.
# Gemfile
gem 'koala'