Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDiego Ante
5,251 PointsGenerate a Rails Application
I'm having trouble generating the application from the command prompt. I'm working on Windows 7 but I can't figure out how to follow along with the tutorial.
15 Answers
Damian Tommasino
96 PointsOnce you create a new rails app (# rails new <app_name>), you go into the directory and start generating the controller/view/models you need. You can also do scaffolding go get everything in one shot.
Generate a controller: # rails generate controller Users
Generate a model: # rails generate model user
Generate a scaffold: # rails generate scaffold Users
Diego Ante
5,251 PointsThank you very much, I think I got it, but the problem is that I have to relaunch the command prompt I do any action, because it seems to freeze, but if I restart it it works ok now and I can follow to the next step.
Damian Tommasino
96 PointsIf you launch the rails server with the "-d" option it should detach from the command line and allow you to work / follow along without interference.
rails s -d
Diego Ante
5,251 PointsThe problem is that I'm not being able to stop the server from the command prompt on windows with ctrl + c
Damian Tommasino
96 PointsYou'd have to look up that process in the task manager most likely and kill it. Unless you are making changes to the DB or authentication you shouldn't have to start/stop the server. The new controllers and models should be accessible immediately without stopping the server.
You could also leverage something like Virtualbox if you wanted to.
Diego Ante
5,251 PointsI'm not understanding anything sorry, I had never worked with the command prompt before :S
Damian Tommasino
96 PointsNo problem :-P
If you are using Windows (assuming you are currently) you can use the -d option when starting the rails server so that the server starts to run in the background. This will allow you to continue working. You don't need to relaunch the rails server each time you generate a new controller.
When you are done working for the day you will need to open the task manager in windows to find the process that is running the rails server, and terminate it.
Does this make more sense?
Diego Ante
5,251 PointsMuch more thank you, but this is the exact command I'm running: "rails server -d" but when I go to http://localhost:3000/ through my browser it says that it doesn't find the page
Damian Tommasino
96 PointsAlso make sure there is no firewall blocking you (although not usually likely for localhost or 127.0.0.1 connections)
Diego Ante
5,251 PointsNothing :(
Jim Hoskins
Treehouse Guest TeacherWhen you are running the server, you can't run other commands, because that window is busy, being a server.
On most operating systems, the way to stop the current task (like the server) is to hold ctrl and hit c (ctrl+c). I believe on windows this sometimes doesn't work, and instead you need to hold ctrl and hit the break key (ctrl+break). This should stop the server so you can run any command, then you start the server again.
running with -d can be tricky because you don't have the handle to kill your server when you need to. If you don't want to restart your server each time you need to run a command, you could use two command prompt windows. However, some things will require restarting the server anyway to update your app (like installing gems).
Hope that helps!
Diego Ante
5,251 PointsThank you! the solution with ctrl+break is working great for now!
have also same problem
Jim Hoskins
Treehouse Guest TeacherHi Jeylan,
Are what operating system are you using? Is hitting ctrl+break stopping the server, and returning you to the command line?
Hi Jim I use wndows xp the command starts with c.// Sites not under Ruby/projects/ treebook as I watched on the video.