It was fairly easy to get things set up for the RubyonRails environment in the Nitrous.IO box, but I am having problems with Preview (the browser utility on the site) to see the apps that seem to be running with the $ rails server command.
My installation shows I have the following installed:
- ruby 2.1.1p76
- Rails 4.1.0
- git version 2.0.0
- SQLite3
When I try to 'Preview' the application running on WEBrick,
I get a default webpage, which says,
Routes are set up in the config/routes.rb
running in development mode and haven't set a root route yet.
I checked the config/routes.rb file in the Nitrous.IO IDE,
and it has the following:
Rails.application.routes.draw.do
resources :comments (from $ rails generate scaffold comment post_id:integer /
body:text [this was second of two commands] )
resources :posts ( $ rails generate scaffold post title:string body:text /
[this was run 1st of these two commands] )
( post and comment database tables created with: $ rake db:migrate )
# lines 6 -> 59 are comments giving coding examples of routes)
end
Any idea on what I need to do in order to 'Preview' development apps ??
Perform the Preview 3000.
You get standard info that app is running
In the browser's address bar add "/(the route you need)" (well without quotes).
In my case it looks like this:
http://blog-137119.euw1-2.nitrousbox.com/comments#index
The "comments#index" was the route I needed.
HTH
/Jacek
Related
https://www.railstutorial.org/book/toy_app
I am really new to programming and I am currently working through the toy_app in chapter 2 of the Rails Tutorial by Michael Hartl and can't seem to figure out how to access the pages created by the "rails generate scaffold User name:string email:string" and "rails db:migrate" commands.
I am using cloud9 through AWS so the book doesn't match completely.
After I ran the "rails generate scaffold User name:string email:string" and "rails db:migrate" commands, I went ahead and ran the local webserver in a separate tab as the book suggests with the "-b $IP -p $PORT" command since I'm using the cloud IDE.
I understand that I have to include "/users" to the root URL as the book suggests in order to get the corresponding page to reflect on the browser rather than just "hello, world!" but I cannot seem to be able to locate the "root URL". I have tried adding "/users" to the URL given to me by the "heroku create" command but all I receive is "The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved" after doing so.
I assume that I am using the wrong URL but I cannot seem to find the one the book is talking about. Any help would be greatly appreciated!
I have an a Rails 3.2 App that show an error for Route not found in production
but not in development. I ran rake Route on my local machine and on the server and the text below show they are identical. I checked the route config file and it was identical and the views were the same. THe exact message I get in production is:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
The two outputs from rakes routes is:
Rake Route Development:
harvest GET /harvest(.:format) visits#harvest
Rake Route from Production
harvest GET /harvest(.:format) visits#harvest
I am stumped is there anything else to look at. THe local machine is a Macbook the server is Centos
I am new to rails and I was able to install rails (3.2.3, ruby v1.9.3), then created a test app:
$ rails new Hello
then I cd'd into the new directory 'hello' and did the following commands:
$ rails generate controller home index
$ rails s
$ rake routes, it gave me
home_index GET /home/index(.:format) home#index
hello /hello(.:format) Hello#index
Then I pointed my browser to: http://localhost:3000/home/index - and it worked great.
Then I wanted to begin a tutorial and it asked me to create a new rails application
so I did like I did before...
$ rails new TutorialApp
$ rails generate controller tutorial index
$ rails s
$ rake routes, it gave me
tutorial_index GET /tutorial/index(.:format) tutorial#index
then I pointed my browser to: http://localhost:3000/tutorial/index, it gave me a message of
Routing Error
No route matches [GET] "/tutorial/index" Try running rake routes for
more information on available routes.
So I ran rake routes again, which it gave me the same output as it did before
tutorial_index GET /tutorial/index(.:format) tutorial#index
Since I created that first rails app "Hello", do I need to turn off that app before starting the new rails app "Tutorial" or they can both be running at the same time?
Any help is appreciated, thanks!
You can use a different port
rails server -p 3001
It will run in a different port. Then, just point to http://localhost:3001
But usually you will probably stop the server on one app and start the other one. It's up to you.
When you run rails server ("rails s"), you're typically running it in the context of the rails project you're in at the time, so before beginning a new project, I would shut down the current server (CTRL C). Also, make sure you create a new rails app in a folder is isn't itself at the root of a rails app. It looks like you might have created your tutorial app inside the root of your Hello app. Sounds like those are the two main things that tripped you up.
I must be missing something, but RoR is just not working for me at all. I have RoR installed where I am hosting, and I have done all of the following:
cd ~
rails rubyonrails
ln -s rubyonrails www/rubyonrails/rails
Added to rubyonrails/public/.htaccess
RailsBaseURI /rubyonrails
Then:
cd rubyonrails
script/generate model User
script/generate controller User list
When I go to http://rubyonrails.truthanduntruth.com/rails/ it seems like it's just not running RoR at all. This might have to do with the fact that I'm using the subdomain. I set up the subdomain with cpanel, so I'm not sure how it's done. The subdomain folder itself is in /home/public_html/rubyonrails
So you can also go to http://truthanduntruth.com/rubyonrails/rails/ . Instead this gives me an error page. This is no better. Based on the error page or my steps above, can anyone tell what I am missing or where I am going wrong?
I'd like to at least get RoR running at all so I can learn it, but preferably I want it to run under the subdomain.
Thanks.
I played around with Rails on my laptop (running Linux + Apache + MySQL) and had no trouble getting the Getting Started with Rails tutorial to work locally. Now I'm trying the same thing at work on a remote Mac OS X + Apache server, and things aren't quite so rosy.
I typed rails blog -d mysql to create a directory called blog in /Library/WebServer/Documents/mydirectory. The trouble is, if I go to server.com/mydirectory/public, I get the public/index.html in my browser. But, I don't get this file if I go to server.com/mydirectory/. Instead, I get a 403 error. Also, when I:
script/generate controller home index
to create:
app/views/home/index.html.erb
I am unable to view this file, whether I go to server.com/mydirectory/home/index, or if I add a new line (map.root :controller => "home") to config/routes.rb and go to server.com/mydirectory.
Am I missing something really obvious about Apache and Rails?
Apache does not support Rails out of the box. You have to get mod_rails aka Passenger installed. Or, you could just use the server that comes with Rails, which is much easier (but not suitable for production). To do this, go to your directory and do ./script/server.