I'm trying to learn ruby on rails but can't manage to have the server working. I've been following 2 tutorials and, every time I come across the server section, for some reason I can't let it work.
First tutorial I tried was the one that can be found at http://installrails.com/
I follow every step and when I get to type $ rails server I get the error explained here Could not find gem 'turbolinks-source (~> 5)'
Since I could get it solved, I tried with the IFTTT tutorial with no better results since after following their instruction and adding the tzinfo-data gem that was apparently missing from their script, I get this log
[2019-06-08 19:12:03] INFO WEBrick 1.3.1
[2019-06-08 19:12:03] INFO ruby 2.3.3 (2016-11-21) [i386-mingw32]
[2019-06-08 19:12:03] INFO WEBrick::HTTPServer#start: pid=4504 port=3000
but still I can't reach the address they suggest (http://0.0.0.0:3000/).
It's pretty obvious to me that I'm missing something, but I really can't wrap my mind around it.
Should it help,
ruby version is 2.3.3p222 and rails one is 5.2.3
When running a Ruby on Rails application on a local machine the following two URL should work:
http://localhost:3000 or
http://127.0.0.1:3000
Btw: 0.0.0.0 basically means all IPv4 addresses on the local machine.
I friendly suggest you follow official rails guides here: https://guides.rubyonrails.org/getting_started.html
they are well written and designated to learn rails. You will find these guides helpful.
Related
I'm trying to get my homework done in Ruby on Rails, but I have already faced dozens of problems because of my lack of UBUNTU (16.04.1) knowledge.
I have installed all the required gems and other clients like MySQL2, Apache2 and Puma. Puma is running, I have two standard tables in MySQL, but there is some issue with my Apache2 connection. I can access localhost:3000 (it says: Yay! You are on rails now!), but I just cannot reach my custom URL-s, that are located in the 'hosts' file.
Could any of you help me with getting started? I could blow my top because I have a lot of work to do and I cannot get through the basic steps of installing the environment...
Thanks in advance!
So I'm a rails developer familiar with Rails 3 and 4. I'm taking on a Rails 1.1.2 project, and the first problem I'm having is getting the server running.
I'd really love some help figuring out what I'm missing setting up the environment. When I run script/server, I get:
-bash: script/server: /Users/michael/.rvm/gems/ruby-1.9.3-p545: bad interpreter: Permission denied
This is after noting that at the top of the script/server file, there's an opportunity to define the location of the ruby install with a ruby comment:
#!/Users/michael/.rvm/gems/ruby-1.9.3-p545
At least, this is how I understand it. What should this comment point to? Does this look correct? I've installed ruby 1.9.3 using rvm and installed rails V 1.1.2 through sudo gem install rails. Everything seemed to work fine.
Is this some kind of bash permissions issue? I really don't understand what's going on. Any help would be appreciated!
I believe a rails project that old will require Ruby 1.8.7, so you should start with an older version of Ruby just to be sure. Once you get it running with the older ruby version, you can try 1.9 again, but trying it with 1.8.7 should help you out a bit. Your shebang should be able to do this though:
#!/usr/bin/env ruby
It needs the path of the ruby interpreter, which can be obtained dynamically via the above line.
I've been following Mike Hartl's excellent Ruby on Rails Tutorial`.
I had to make some decisions earlier about versions for gem files and ruby. I decided (after some problems getting Heroku to work that I'd directly mimic the tutorial and versions of ruby described - leading me to go with rvm use 2.0.0 to set my version of ruby.
All was great on chapter one but now I'm getting an error message when i try to create a new rails project:
$ rails new demo_app
/home/huw/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- rails/cli (LoadError)
from /home/huw/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/bin/rails:9:in `'
I have no idea what that means... but as its referencing my ruby version I'm guessing that my rails and ruby versions are out of sync...
Could someone advise on possible courses of action?
I imagine possible options would be:
Reset my ruby version to the latest (but I don't know what clashes
that would create with gems!)
Downgrade from rails 4.1 to rails 4 (I believe that's Mike Hardl's version)
Force things through somehow
I'm a complete rails Noob however, and have no idea where to begin on any of those options - or if that error code even backs up my assumptions!
Forgive the "answer" but I don't have the rep to post a mere comment :-(
Have you tried looking at the RVM site? It has a troubleshooting page that may help you.
If not, have you tried get rvm stable and then typing in the rails new app_name command?
Other useful RVM commands are rvm list rubies and rvm gemset list. It may be the case that the ruby version you're using doesn't have rails for some reason.
As per zwippie's answer in the comment section, the solution was achieved as follows.
rails -v produced a very similar looking output to the error message above.
gem install rails after hanging for a second installed rails successfully. I am now able to add a new project.
I'm unsure why this has happened as I've been successfully making new rails projects both on this laptop and in this directory for the last two weeks, even up until this morning. However as zwippie notes perhaps this is an RVM setup issue. I'll go away and read up but if anyone had any additional pointers from documentation that might shed light on the issue I'm appreciate any links in the comment.
Many thanks all.
check for the rails is installed on your machine by the command bundle show rails.
If you get the version of rails and are still getting the above error, to resolve it you may have to use the command bundle exec before every rails command as in bundle exec rails s.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I am a Newbie on Ruby on Rails, and I've had some issues with the deployment of RoR applications.
EDIT 1: Trying to narrow down the question a bit. I am uncertain whether my issues with the deployment of my rudimentary Ruby apps are results of my erroneous setup and coding or conflicts in the version of Ruby on Rails I am currently using.
Rephrasing question: What version of Ruby on Rails should I use? Being a newbie to the frameworks, I just want my deployment process to be as smooth as possible. If 3.2 is the official download (as of jan 20, 2012) is it safe to use, and should I then use the latest stable version of Ruby (1.9.3-p0)? What about gems mentioned in books and writings? Should I always use the latest one?
Old discussion
I am following Ruby On Rails Tutorial. Following the instructions in the book I try to deploy on Heroku, but with no luck. Printouts from the Heroku log gives:
2012-01-22T18:26:09+00:00 app[web.1]: Started GET "/pages/about" for 90.231.141.39 at
2012-01-22T18:26:09+00:00 app[web.1]: cache: [GET /pages/about] miss
2012-01-22T18:26:09+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished
(ActiveRecord::ConnectionNotEstablished):
This application does not use any database at this point (only presenting static pages). So to me the ActiveRecord error comes as no suprise. Uncertain though if this is the root to the problem. I first thought that this issue was realted to Heroku, since my rails server deployment worked fine, but the I found the rails server -e production command to run the rails server in production environment. Under Rails 3.1.3 this renders the page correctly, but I still get the following error message in the server log:
sample_app$ rails server -e production
=> Booting WEBrick
=> Rails 3.1.3 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-22 23:07:28] INFO WEBrick 1.3.1
[2012-01-22 23:07:28] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-22 23:07:28] INFO WEBrick::HTTPServer#start: pid=57161 port=3000
cache: [GET /] miss
cache: [GET /pages/about] miss
Started GET "/pages/about" for 127.0.0.1 at 2012-01-22 23:09:50 +0100
Processing by PagesController#about as HTML
Rendered pages/about.html.erb within layouts/application (2.0ms)
Completed 200 OK in 24ms (Views: 24.2ms | ActiveRecord: 0.0ms)
cache: [GET /assets/application-cd728f3a08415c27ca2e753d30091c74.css] miss
It seems to me that there is some kind of routing issue. But my lack of knowledge and experience with RoR makes me a lame duck in the search for the actual error.
Upgrading to Rails 3.2.0 made the issue even worse. I made a sample app for Rails 3.2 basically with:
rails new test_app
Entered the "test_app" folder and ran rails server -e production (using Ruby 1.9.3-p0). This time the default Ruby on Rails index page was not even rendered. The server log gives me:
heroku_test$ rails server -e production
=> Booting WEBrick
=> Rails 3.2.0 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-22 23:19:07] INFO WEBrick 1.3.1
[2012-01-22 23:19:07] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2012-01-22 23:19:07] INFO WEBrick::HTTPServer#start: pid=63242 port=3000
cache: [GET /] miss
So, it seems in all cases like I have some issues with my routing or my caching or wathever.
These are my specs:
System specs: Mac OS X Lion 10.7.2
Ruby: 1.9.3-p0
Rails: 3.1.3 (and also 3.2.0 release the other day)
I am very aware that these specs are not what Ruby on Rails Tutorial propose. The RoR tutorial is written with the follow Specs in mind:
Ruby: 1.9.2 (or 1.8.7)
Rails: 3.0.11
In chapter 13, Hartl explains the difference with Rails 3.1.x and sports an upgrade guide for the sample_app. I've skimmed through this chapter (since I am stuck at chapter 3) but have been unable to find a remedy to my problems.
What is my question really?
How do I deploy a RoR app to production for a version of RoR that runs on my system?
Related links and sources I've browsed so far, apart from the regular pages on RoR.org and Heroku.com:
cache: [GET /] miss? dalli gem, memcached, rails 3.1, nginx, unicorn production environment
How does one load a CSS framework in Rails 3.1?
rails 3 tutorial: No route matches [GET] “/”
Rails 3.1 on Heroku Cedar
Now that the question has changed:
"What version of Ruby on Rails should I use? Being a newbie to the frameworks, I just want my deployment process to be as smooth as possible."
If you are learning from a book or tutorial, use the same version as the examples in that book/tutorial.
"What about gems mentioned in books and writings? Should I always use the latest one?"
Most gems have dependencies on other gems, so the exact version you use will often depend on those dependencies. Sometimes you may even discover a bug in one version, so you switch to another version to remedy the problem. Or again, if you are following a book/tutorial which uses a certain version, you may want to use the same version (at least while you are working through the tutorial). If, though, you have no good reason to use an old version, then generally you should use the newest one.
Have you learned how to use Bundler? It allows you to control the exact versions of each gem which you want to use.
#jollyCocoa, the error you got when deploying to Heroku was caused by not having the database set up. Even if you're not using the database, if you configure the database connection anyways, it will fix this error. If you are starting with RoR, though, and just want something to experiment with, don't try deploying to Heroku at this point. Just start with a very simple application running locally, even just the "skeleton" application generated by "rails new", and make changes one small step at a time, checking at each step that the app is still working. If you get stuck and can't figure out how to get a certain feature working, you can post a more specific question.
I have just started to learn Ruby on Rails and in going through a tutorial I am not able to launch the rails project because of the following error.
-e:4:in `load': no such file to load -- script/server (LoadError)
from -e:4:in `<main>'
I have installed Ruby 1.9.2 and using RadRails as the IDE for creating and executing the Rails project. Any suggestions?
Most likely your tutorial refers to Rails 2 (for which given command works), while you're using Rails 3.
I'm not sure how exactly you start server in Rails 3 (edit see answer by jdl), but take my adice: find another tutorial. Otherwise, you'll have to create such questions here several times a day :)
If you just installed the latest Rails the the command has changed (as of Rails 3) to:
$ ./script/rails server
I think the best way to start a server in Rails 3 is to run this command from the root of the project:
rails server
You should have the rails executable in your path if you've installed the Rails 3 gem.