I couldn't find anyone else with this problem so I thought I'd ask.
rails new myNewRailsApp
This works fine.
cd myNewRailsApp
ls
Reveals everything seems to have generated properly.
rails server
This creates a new directory "server" and creates a new rails application. It also seems to happen with "generate" and other command words. I'm on version 3.0.9 (considering rolling back now), and I purged it, all gems, and reinstalled. Am I missing something obvious?
Edit: I'm running on Ubuntu 11.04.
Looks as though it's using Rails 2 to generate a new app within your app. I've done this a few times and the amount of apps I've created with app names of "c" and "s".
To get round either use
bundle exec rails server
or
script/rails server
Or uninstall rails 2 from your system
Seems like the command is still using 2.x version of rails.
If you want to use multiple versions of rails for different projects use rvm to create gemset for each rails version.
[http://beginrescueend.com/][1]
If you dont want to use rvm, uninstall older versions of rails and try re-installing rails 3.x.
Related
Forgive me if there's a duplicate, but I'm honestly not sure what to search for. I'm working on a project with Ruby on Rails, and I get this message when doing anything related (ie: rake, rails, rspec, etc.):
Your Ruby version is 2.1.5, but your Gemfile specified 2.2.3
Now, I've installed RVM and I can fix this issue by issuing the command
bash --login
edit for clarity
running the above command does use Ruby 2.2.3 to execute the commands.
/edit
Then those given commands work. What I would like to do is to remove version 2.1.5 entirely -- leaving only 2.2.3. I've gone about this so many different ways, but Ruby is pretty foreign territory to me so I'm not sure what to do about this. I'm sure I have at least three installations of Ruby on my machine - possibly two duplicates of the two versions I know I have - and I would like only one version and to avoid needing to enter the bash --login command in order to run my project.
I'm running Ubuntu 15.10 and have at least some knowledge of how this works. If somebody could walk me through removing everything related to Ruby & Ruby on Rails, then installing only Ruby 2.2.3 and Rails 4.2.4, I would greatly appreciate that. Let me know if this isn't the proper exchange for this question. It didn't quite seem to fit into Ubuntu or Sysadmin.
What you need to do is not try to remove ruby 2.1.5.
You have RVM, so, use that to get the new version you want.
After this, you now have two options:
1) make the newly installed version the global default version on your machine,
or
2) create a gemset for your project, and specify the needed ruby version for the project.
Either of these will fix your problem.
You have to modify the Gemfile.
http://bundler.io/v1.3/gemfile_ruby.html
I am facing issue when I am trying to work with rails 3.0.11. I initially worked with rails 3.2.6. Build a prototype application in Rails 3.2.6, Ruby 1.9.2 and gem 1.8.7. But then found, server on which we need to host is a shared server which can only support Rails 3.0.11, Ruby 1.8.7 and gem 1.7.2.
Hence I want to keep my dev environment exactly same before I ran into further issues. As I found there was some discrepancy in routes.rb of both the versions.
Steps I followed:
Uninstalled rails
Uninstalled ruby
Installed ruby from here.
This installed ruby version 1.8.7-p370 and gem 1.8.7
After this I installed rails by specifying version as 3.0.11
But still when I run command rails -v, it throws an error to me saying 'missing gem rails 3.2.6. Run bundle install to resolve the issue'
When I ran bundle install, it again completely installed rails 3.2.6 and problem remained unresolved.
Please suggest the clean way how shall I start my development on rails 3.0.11 without running into any issues?? Am I need to delete some registry or mapping in my system through which it is detecting rails 3.2.6 and creating issues??
Its urgent as I need to complete my dev by 7th September.
As I am new to stackexchange, please guide is it appropriate to ask question on the same related thread or shall I open new discussion for my problem?
#Gun - please note in response to one of your comments posted above - you DO need to change your Gemfile - if you are running rails -v from withing your project's directory, it will read the Gemfile.
There is a script located at script/rails - this is what runs when you run the rails command from the project directory. NOTE that this rails script requires your config/application.rb file - which in turn reads the Gemfile and bundles the referenced gems. Thus is your Gemfile still references 3.2.6, and it is not installed, rails -v will not work
Glad to hear the problem is fixed :)
As for the asset pipeline - if you are using rails 3.2.6 (or were using it) then you may have been using the asset pipeline to serve your assets (javascript files, CSS files, images, etc). If you were, and you downgrade to anything pre rails version 3.1, then anything being served through the asset pipeline will no longer work.
Here is a pretty good description of the asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html
You should check also remove your Gemfile.lock or manually 'bundle update rails' when you change your rails dependency.
I suggest to use rbenv or rvm to create a virtual environment/sandbox where you can install your preferred ruby versions (e.g. 1.8.7) and keep tracking of your dependencies separately. This would save you a lot of effort.
Keep in mind that rails 3.0 has no asset pipeline support (it has been included in rails 3.1)! This is a very important difference and if you depend on it you will have big issues to solve for the downgrade.
Thanks a lot everyone for help.
I believe it was weird issue. I had heroku on the system. I was initially deploying my app on the same and then changed to another hosting server.
After uninstalling the heroku, it works perfectly fine. Probably, that was interfering somewhere. Although, not sure but problem is resolved.
Thanks a lot again for a great great help!!!
Meanwhile, I would request alup to throw some more light on asset pipeline support. Wots that? Could you please explain more??
Need to delete C:\Users\.ror folder and C:\Users\.gemfile and C:\Users\.gemfile.lock from your desktop..
I upgraded to the latest Rails v3.1.3. And everything is fine, I'm able to run the 2.3 version of one website and the app for v3.1.3.
However I couldn't move it to a new machine, I installed all the required gems with
bundle install
and just cannot start Thin with the 2.3.2 version. I can only run the v3 apps. Thanks
Go read about RVM, and try to configure you machine according to the instructions given there.
As #Syed Aslam said the ideal way of doing is using RVM, but you may set bundler to your Rails 2.x project (because rails 3.x already have bundler..) and run both your projects in the same machine (actually currently I'm doing that).
Following is a tutorial how setting up bundle with Rails 2.x.
I'm beginning to learn Ruby on Rails, I installed the latest ubuntu release on a VMWare machine and started the ruby on rails setup process using the mini-guide in this online book (which was recommended in stack overflow more than once). I'm wondering:
As part of my environment setup process I installed RubyGems and used it to install Rails (which is, if I understand correctly - a gem itself) the first time.
Now, when creating a new project using rails new project_name I later on edit the Gemfile and specify "rails '{version}'", which, from what I understand, installs the Rails gem in the context of the project (after using bundle install)...
Why would I need both of them? I'm kind of confused and would be more than happy if someone could shed some light over this...
Yes, this is a bit confusing.
When you run rails new project_name, you are using whatever rails executable is available in your shell to start a new rails project. To see what version this is, run rails —version. This does not "install the rails gem" — it just generates the tree of files to get you started on a new rails project.
You'll then specify in your Gemfile which version of rails your project will use.
So, be sure to have the latest version of rails available to your shell when you generate your new project, so that you get the newest version of the files it generates.
I am new to Ruby on Rails and am following a tutorial to create a class project.
I can generate a new rails project with
$ rails project
The problem Im having is when I try to start my server, It will generate a project called server:
$ rails server
or
$ rails s
I figured out that I need to install/update rails to 3.0.3 to use this command every time I open terminal. I find myself having to install gems(bundle, etc) every time I need to work on my project.
Is there anyway to save this terminal session or profile for later use?
Is it user error?
Im new to Rails and about the same with terminal.
Any help would be greatly appreciated. I have resorted to leaving my computer and terminal open for about a week...
Welcome on board! - You'll have fun, I found setting up the environment the most difficult thing.
in rails 2 you start the server with ruby script/server.
to upgrade to rails 3 try gem install rails -v=3.0.4
I put the version but it's not a mandatory option.
To uninstall a gem (as rails is) is gem uninstall gemname -v=x.x.x. -
gem list will tell you the version of each gem.
I hope you've got rvm, if not I strongly sugget you to install it, this will allow you not only to use different versions of ruby but also to set different gemsets, therefor one each project, you'll find it useful.
Once in rails 3 you can use bundler, have a look at this episode of railscasts, by the way this is a very good site, but you may know it already.
another edit...
I don't know the behavior you're describing, looks like something is wrong with your environment, but I need to know if you have rvm to solve this, if so try rvm list and rvm gemset, With the first you get the list of installed ruby, you can switch between them with rvm 1.9.2 i.e. and rvm 1.9.2#gemdirname with the gemdir coming from the second list. You should find your configuration in one of those list.
Hi if you are using rails 2.8 or lesser use this to start the server
ruby script/server
rails new project is for new rails project n rails s is for starting server