rails not recognizing project - ruby-on-rails

I can create a new project using rails and I can use stuff like
rails migration ...
and i (correctly) get a error because the sqlite gem is missing.
but when i try using rails migration ... with a project i checked out from github, it doesn't recognize that it is a rails project i get:
Usage:
rails new APP_PATH [options]
Options:
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
-O, [--skip-active-record] # Skip Active Record files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-test-unit] # Skip Test::Unit files
-G, [--skip-git] # Skip Git ignores and keeps
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
[--edge] # Setup the application with Gemfile pointing to Rails repository
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /usr/bin/ruby1.8
[--skip-gemfile] # Don't create a Gemfile
and it goes on. any ideas?
edit: it's probably an important detail that earlier my rails wasn't working at all. i had to cp /usr/bin/ruby to /usr/bin/local/ruby

I suspect the project from Github probably uses Rails 2.x and you probably have Rails 3.x.
Either that or perhaps you just forgot to "cd" into the folder after getting it from Github.
You mentioned that earlier your Rails wasn't working at all. If that's the case and if you need to switch among different versions of Rails, a really nice thing to try is rvm. It's really popular: http://rvm.beginrescueend.com/

Related

rails server not starting - trying to run code from ryan bates railscasts application with rails 3

I am trying to work with ryan bates' sample code that he uses for his railscast on Daemon (episode 129). I have rails 3 installed, and when I downloaded his code, I cannot run the server. To try and fix this, I copied my gemfile and gemfile.lock from a standard rails 3 application, and put it into his application, then ran bundle install. Still, my rails server does not respond. Instead, I get the following (see below).
My guess is that I am having issues because railscasts uses rails 2 (I believe) whereas I am using rails 3. Is there any way that I can still use his program?
Thanks.
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/kyala/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)enter code here
# Default: sqlite3
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--dev] # Setup the application with Gemfile pointing to your Rails
checkout
[--edge] # Setup the application with Gemfile pointing to Rails
repository
[--skip-gemfile] # Don't create a Gemfile
-O, [--skip-active-record] # Skip Active Record files
-T, [--skip-test-unit] # Skip Test::Unit files
-J, [--skip-prototype] # Skip Prototype files
-G, [--skip-git] # Skip Git ignores and keeps
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Supress status output
-s, [--skip] # Skip files that already exist
Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit
Description:
The rails new command creates a new Rails application with a default
directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
this is not going to work this way. there are too many differences between rails 3.x and 2.x (different behavior of rails command, different config, bundler etc).
i would create a new rails project and just copy the app folder from the screencast.
anyways, this is not a good idea, as the gems that are used for rails 2.x are different from those in rails 3.x so you will most likely experience some errors with this approach.
To run server in rails 3 you should use following command from your source folder:
rails server
But I think it's easier to install rails 2 and appropriate version of ruby than trying to fight issues of migrating from rails 2 to rails 3. To switch between different ruby version you may use rvm.

Not able to run rails server

Any suggestions on why am I getting this? My ruby version is ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0] and rails version is Rails 3.1.1. I have done bundle install and gem update --system.
➜ expertiza git:(master) ✗ rails server
Usage:
rails new APP_PATH [options]
Options:
-j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library
# Default: jquery
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/vsingh3/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
-J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
-G, [--skip-git] # Skip Git ignores and keeps
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
-b, [--builder=BUILDER] # Path to a application builder (can be a filesystem path or URL)
[--old-style-hash] # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3
-O, [--skip-active-record] # Skip Active Record files
[--skip-bundle] # Don't run bundle install
-T, [--skip-test-unit] # Skip Test::Unit files
-S, [--skip-sprockets] # Skip Sprockets files
Runtime options:
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Supress status output
Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
Thanks!
I encountered this same problem a while back and I think it was due to an outdated gemfile. Make sure you have the same version of rails listed in your gemfile as is installed on your machine.
You should look in to using RVM if you don't currently. It will keep all of your environments for different applications separate (including ruby versions and gem lists/versions).

Rails new command not working

I run rails new search in my console, and I get all of this:
Usage:
rails new APP_PATH [options]
Options:
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-test-unit] # Skip Test::Unit files
-G, [--skip-git] # Skip Git ignores and keeps
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
[--edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-O, [--skip-active-record] # Skip Active Record files
Runtime options:
-q, [--quiet] # Supress status output
-s, [--skip] # Skip files that already exist
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
But it doesn't actually create the application. What's wrong here?
turns out I needed to install the rails gem again: gem install rails
Have you tried rails new ./search ?
I just tried it in windows, Ruby 1.9 w rails 3.0.9 and didn't have that problem.
If you're using RVM, try creating a new gemset and then install rails.
rvm gemset create better
rvm gemset use better
gem install rails -v x.x.x
rails new betterApplication

Can't generate new app with Rails 3.0.6 or 3.0.7

When I try to generate a new app with Rails 3.0.6 or 3.0.7 installed I just get the instructions for using the rails command. For some reason Rails seems to think that I have typed in the wrong syntax (which I haven't, of course). Everything works fine in 3.0.5 or lower, though. I run Ruby 1.9.2 and Ubuntu 10.04.
rails new app
Will result in:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /usr/local/bin/ruby
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository
[--skip-gemfile] # Don't create a Gemfile
-O, [--skip-active-record] # Skip Active Record files
-T, [--skip-test-unit] # Skip Test::Unit files
-J, [--skip-prototype] # Skip Prototype files
-G, [--skip-git] # Skip Git ignores and keeps
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
-q, [--quiet] # Supress status output
-s, [--skip] # Skip files that already exist
Rails options:
-v, [--version] # Show Rails version number and quit
-h, [--help] # Show this help message and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
try updating rubygems;
$ gem update --system
It seems running rvm rubygems current breaks this, at least for me.
I ran the command as it was mentioned here that it would get rid of all the deprecation warnings, running gem update --system fixes it, and brings back the deprecation warnings.

rails - problem starting the server

I'm trying to start the server on a rails app. with some apps it works fine, others I get this message:
rails s
Usage:
rails new APP_PATH [options]
Options:
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
-O, [--skip-active-record] # Skip Active Record files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
-J, [--skip-prototype] # Skip Prototype files
-T, [--skip-test-unit] # Skip Test::Unit files
-G, [--skip-git] # Skip Git ignores and keeps
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL)
-b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL)
[--edge] # Setup the application with Gemfile pointing to Rails repository
Runtime options:
-q, [--quiet] # Supress status output
-s, [--skip] # Skip files that already exist
-f, [--force] # Overwrite files that already exist
-p, [--pretend] # Run but do not make any changes
Rails options:
-h, [--help] # Show this help message and quit
-v, [--version] # Show Rails version number and quit
I'm using Rails 3.0.3 and ruby 1.8.7
I think you are trying to run Rails 2.x applications with this command. It will fail with this message. Since its consistently failing on certain apps, check if they are rails 2.x apps.
You can only run Rails 3.x applications with this command.
You must be missing script/rails file. Maybe you removed it by accident, or did something wrong while upgrading from Rails 2. Just copy it from a working project (or a new one).
My guess is that you are including a character after the 's'. If you type "Rails s" it will work but not if you type "Rails s ".
It is consistent with which apps work and which apps do not work?
I had the same issue. I figured out the problem was created by deleting rails 4.0.0beta1 from my system. I still had version 3.2 installed but I think the deletion deleted the scripts folder as well. After typing
gem install rails
It worked again. Maybe this helps someone.

Resources