Rails - bin/rails generate doesn't work in recreated project - ruby-on-rails

I've just red "Getting Started with Rails" and trying to create a blog project again from scratch.
I've created a new environment for rails projects with vagrant/virtualbox/ubuntu 12.04
Here is the problem.
I've create a new rails project with
rails new blog
Thereafter, using
bin/rails generate controller pages
I've create a controller, and continued working with project. After some time, I've decided to delete the blog project and start again from scratch.
I've started a new iteration
rails new blog | works fine
cd blog
bin/rails generate controller pages | does not create a controller, does not terminate, only with control + C
I've repeated all steps with a new project blog2. And the result was the same. If i create a new project, then delete it, then create a project with the same name
bin/rails generate
will not work.
Rubu 2.1.3/Rails 4.1.6
What should I do to fix it?

Solved by executing:
spring stop

I had a similar issue when using RVM. I had to close that terminal, opened another terminal, then switched back to that version of ruby.
After that everything worked fine again.

Related

Error: Rails command not found

I created a new Rails project in a directory, say Desktop (rails new project1). After that, I ran the following command:
rails server
Then, the project1 was running on localhost.
After that, I made another directory with name (project1) in another location. I copied all the files from the previous location to new location. After that, when I ran the following command:
rails server
I got the following error message:
Rails is not currently installed on this system.
But it is working in the previous directory. How do I solve this?
If you are totally new to Rails development and System administration it is rather complicated in the beginning. I recommend any kind of Rails tutorial to you for examply by Michael Hartl .
As Graeme McLean points out you somewhen understand that there is information about your environment needed to help you.
Most likely the requirements you need to be set up are not set up in the place you did copy your rails project as Pavan and Thaha kp pointed out.

RubyMine is showing the error message: "Error running Development: MyProject: Rails 3.x launcher script was found instead of Rails 4.x one"

I'm updating my project from Rails 3.2.12 to 4.0.0.
I made all necessary corrections but when I try to execute my app using RubyMine 5.4 I'm receiving the message below:
Error running Development: MyProject: Rails 3.x launcher script was found instead of Rails 4.x one. You need '/Users/stackoverflowuser/RubymineProjects/MyProject/bin/rails' script to launch Rails server. Please update server launcher according to Rails 4.x documentation.
What am I doing wrong?
"Hack" solution:
Create a new Rails 4 project: rails new MyTestRails4Project
Copy the bin folder that is within the MyTestRails4Project
Paste bin folder inside the project that has just been migrated to Rails 4
Update
If the first solution doesn't work, as RiPuk suggested:
Run the rake task: rake rails:update
The accepted answer is a bit of a hack - it sounds like you've not finished the upgrade of your project from Rails 3 -> Rails 4.
First thing to do is to run the rake task that interactively updates various files (environments, configs etc) to Rails 4:
rake rails:update
Then assuming that you want to use Spring (of course you do!), run this:
spring binstub --all
it's a problem related to the IDE configutration, one quick solution to this is:
close the project
remove .idea folder
open project
Profit!
if it does not work, try to create a new project (rails new project) and copy the db and app folder from your original project to the new project and create the database using:
rake db:schema:load
I hope this helps.

How to create a new Rails application from existing source code

I've been tasked to get a Ruby-on-Rails application working on a dev machine. We have the actual source code (after generation) on a DVD.
I've installed Ruby and Rails, and confirmed both to work. I've copied the source code into C:\Sites.
I'm completely new to the whole stack and googling has given me no help.
Update: took the equivalent of a working day spread over two days. thanks for the answer. got it done in the end. o_O
If you already have the code than fire following commands and you are ready to go
cd "your project"
bundle install
rake db:migrate
rails server
and goto http://localhost:3000

Cannot start project in rails

I'm pretty new to Rails.
I created a new Rails app: rails new app_name, and ran rails server etc.
But, once I shut down and reopened my machine, I can run neither rails server nor rails console. It says to use the rails new app_name command again, but I just want to restart where I left off the day before.
Any advice is very much appreciated.
I'm guessing your current working directory of your command line is not in your project directory which you created yesterday.
cd some_path/to_my/rails_project
rails server
You must be in the directory that represents your project to do things like launch the server. Otherwise, how does it know what project to launch a server for?
Just make sure you are in the directory of the rails app you created. Sounds like you aren't.

NetBeans hangs up while creating a Rails project

I'm using NetBeans and I'm trying to create a new Rails project trought the wizard, so while I click the finish button, it creates the folder structure but the wizard never finish working and doesn't show nothing on the Projects view.
It just happens when I set up a Sqlite3 DB.
I'm using Rails 3.0.7
Can someone help me?
I have always struggled to create Rails projects using the internal netbeans wizard. Usually I find it easier to create the rails app from the command line:
rails your_app_name
This will create a new folder your_app_name in your current location, and then I create a new project within Netbeans by selecting the 'Ruby on Rails Application with Existing sources' option. And select the freshly created your_app_name folder for the Project folder.
I have found Netbeans to be less reliable with rails 3+ applications than the 2+ and find that run most rails commands directly from the terminal/command prompt.
do you have sqlite3 installed? Anyways people will be able to help you if you can post the netbeans log. Go to the command line and run netbeans from the command line. Then you can see a lot of output/logging info.

Resources