I'm following Michael Hartl's Ruby on Rails tutorial book and am trying to install rails. As the book says, I followed the instructions on InstallRails.com and got through most of it until I was told to run rails server and I kept getting the error that I didn't have railties gem not installed. I had initially ran sudo gem install rails and so I read that it didn't pick up railties for some reason but gem install rails did - so that fixed it. So now I was able to run rails server and the app was live.
I returned to the book and as the instructions say, I generated a new rails app, specifying the rails version (4.2.2). However, when I run rails again, I get errors. At this point, having tried a dozen different stackover flow solutions, I feel like I must have screwed up the files and maybe I should just get rid of rails completely and try installing from scratch.
Here's some information on where I'm currently at:
Faiques-MacBook-Pro:Desktop Faique$ rails -v
Rails 4.2.3
Faiques-MacBook-Pro:Desktop Faique$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
Faiques-MacBook-Pro:Desktop Faique$ mkdir workspace
Faiques-MacBook-Pro:Desktop Faique$ cd workspace
Faiques-MacBook-Pro:workspace Faique$ rails _4.2.2_ new hello_app/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (= 4.2.2) - did find: [railties-4.2.3] (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/ ubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
I'm not sure what other information I should provide.
This isn't an ideal solution but what I ended up doing was completely restoring my mac and then reinstalling rails but using rbenv instead as per a friend's recommendation. I am now set up with Rails.
I wanted to do a complete restore (deleting all my data) because I had tried so many stack overflow answers for different errors - including using sudo for certain commands - that I'm sure I had messed some important settings and would take a long time to figure out. I think this was surprisingly one of the more efficient solution, although far from ideal.
Related
I am Ruby/Rails beginner, and I am on Windows.
I just used RailsInstaller to upgrade from Rails 3.0.9 to 3.2.3, from Ruby 1.8.7 to 1.9.3. The gems that I installed previously no longer appear when I type gem list. I assume this is normal.
My question is: Is there a way to get all of those gems "into" Ruby 1.9.3 without individually re-installing them?
When I went into an old rails apps and ran bundle install, it appears that a few of my gems were re-installed (the ones in the Gemfile).
Any help would be appreciated. Sorry if I am missing something obvious.
If you're just upgrading to a new version, as long as everything that was in your Gemfile was installed when you ran bundle install then I wouldn't worry about it. Just re-install gems as you need them instead of bloating your system with gems that you don't currently need.
If you have projects that you are porting over to the newer versions of Rails and Ruby, you can just run bundle install as the first step in upgrading the app to make sure its dependencies are installed.
Maybe someone could give you an yes/no answer for transitioning with RailsInstaller, but I'm trending toward using rvm and gemsets to have a cleaner, more focused environment for each project.
If you want to switch back and forth between multiple ruby versions, maybe check out the gem pik. You can use it to install gems on multiple versions of ruby so that they're available across them all.
So I finally upgraded (and then downgraded because of Unity) Ubuntu and reinstalled RVM but I'b stuck with rails 3.1 now, which is fine but all my old projects are in rails 3.0 and 3.1 has some incompatibilities. Off the top of my head RAILS_ROOT is now Rails.root (which all my projects use in someway), and I was having some issues with heroku when trying to upload a small rails 3.1 app I made to play around (since the PG gem wasnt in my gemlist I couldnt run migrations, and then installing the pg gem caused more issues).
So how do I install rails 3.0 again? I cant seem to find it in the repositories
And I know with gem sets I can install both right? Well if I do that, how do I create a new rails project? Which version of rails would use rails new new_app?
Ok, I understand what you need to do. I would highly recommend making a new Gemset using RVM, that way you can start from scratch and not worry about those things.
To do that, run this in your command line with RVM installed:
// EDIT THIS LINE TO MATCH WHAT YOU WANT
rvm use 1.9.2-or-which-ever-version-you-are-using#temporary_gemset --create
Once this gemset is created, it will be empty, so you can then proceed to install a younger version of rails, like so:
gem install rails -v 3.0.11 // (MAY NEED TO USE SUDO, DEPENDING ON YOUR SET UP)
This should install the older version of rails and its dependencies so that you can still edit and work with your older rails project. Check more of RVM's site for more help on switching between gemsets and creating them.
https://rvm.io//gemsets/
I would still recommend to figure out the differences eventually and move to the newer version for Rails, currently 3.2.5 because they are awesome. Here is some material to show you the differences and new features for when you do that later:
http://railscasts.com/episodes/265-rails-3-1-overview
http://railscasts.com/episodes/282-upgrading-to-rails-3-1
http://railscasts.com/episodes/318-upgrading-to-rails-3-2
I wanted to use this gem:
https://github.com/PRX/apn_on_rails
Finally, after digging through the issues, seems it's not Rails3 ready (yet). Is there some simple way of finding is something is Rails 3 compatible without digging all over?
Thanks!
Aside from creating a fresh Rails app and giving it a try, I tend to look at the commit messages of forks created by other users (i.e. https://github.com/PRX/apn_on_rails/network). In this instance, it looks like there is a fork that runs on Rails 3 that is still being maintained.
Generally, if it isn't mentioned in the readme (on github) then no. Most gems I have used explicitly specify rails 2 and rails 3 install instructions. If this is not the case, then usually someone else will have asked this question and a quick search will reveal.
One other giveaway is the install instructions. The rails 2 way of installing a gem via a Gemfile is:
config.gem GEMNAME
The rails 3 way is:
gem 'apn_on_rails'
This answer is related to the gem you are looking for.
So I am somewhat new to Rails 3, and I am trying to integrate Google Maps with my Rails application.
I installed ym4r_gm from git://github.com/rorcraft.ym4r_gm.git, and I followed the tutorial on http://blog.brijeshshah.com/google-maps-in-ruby-on-rails/, and http://blog.brijeshshah.com/google-maps-in-rails-3/ .
After following the tutorial, I tried to run my application but I get an error that says "uninitialized constant ActionView::CompiledTemplates::GMap" regarding the "<%= raw Gmap.header %>" line. I have already installed the ym4r_gm-0.2.0 gem, and the ym4r-0.6.1 gem. Any suggestions on how to solve this problem?
Make sure that the gems you're trying to use in your Rails app are actually included in your Gemfile as well as being installed on your local machine.
Check out Ruby Gems for the exact line to include in your Gemfile. In this case, it's:
gem "ym4r_gm", "~> 0.2.0"
When you push your code to a production server like Heroku, the Gemfile tells Heroku which gems to pull down and install on the server. Also run this command when you're done.
bundle install
I'm sure this is astonishingly straightforward, and I'm just inexperienced with Rails 3, but I can't figure out how to make it work.
I'm trying to install the paper_trail plugin into my Rails 3 app; but the instructions seem designed for Rails 2. I'm running under Windows, and don't have git available.
I've tried putting gem 'paper_trail' into my Gemfile and running bundle install, which picked up the gem correctly; but rails generate paper_trail (which I assume is the new form of script/generate paper_trail fails with Could not find generator paper_trail.
Can anyone give me some step-by-step instructions to get this working?
A little late to the party. I am writing this since I found the thread through Google. Here is how I got it to work with Rail 3.0.9. I was getting the same error with
bundle exec rails generate paper_trail
as well as
bundle exec rails g paper_trail
and
rails generate paper_trail
Turns out, you need to run
bundle exec rails generate paper_trail:install
that generated the migration file for me and a
bundle exec rake db:migrate
created the table.
As of 11 October, rails generate paper_trail works as you would expect.
I've managed to make this work by simply downloading the zipped code from github, unpacking it into vendor/plugins, installing the gem (through Gemfile and bundle install), and then copy-pasting the migration code in paper_trail's generator into a blank migration of the same name.