I’ve been trying to complete this tutorial here: http://rubysource.com/building-your-first-rails-application-models/ (as well as compared with the code from here, http://dorkbyte.com/2012/07/31/teach-yourself-ruby-on-rails/, because the second author claims the first author has some errors). I’ve finished it, but there are several problems that don’t reflect what should occur according to the author.
One. In the routes.rb file in the config folder, the code:
resources :urls, :only => [:show, :new, :create]
[Comment line (StackOverflow increases text with a hash] redirects main to app
root :to => redirect('/urls/new')
The server still loads the standard page; according to the author, this shouldn’t happen. It should redirect to the application.
Two. I actually corrected my other two problems while typing this, but I do have one question for RoR developers in Windows. When saving the .RB files, many times I’ll see four and five files of the same kind, like:
urls_controller
urls_controller ~
urls_controller ~~
urls_controller ~~~
I’ve seen this with other Windows files, like Excel, Word and the like, but they go away after saving the program. With these RB files, even after a save, they don’t disappear and leave the original. I even restarted my computer to see if they would go away, and they didn’t. Is it normal to have multiple RB files with only a count of ~ difference, or is this some kind of error/bug?
Edit: I really, really don’t know why StackOverflow can’t grasp the concept of 1. then 2. without changing my 2. to 1. again. So I just made them text values.
You mention in the comments that you have an
index.htmlfile in yourpublic/directory. Rails will prioritize this file over anything inconfig/routes.rb, so when you go to the root URL it will serve that file (hence you see the default Rails page rather than the new url page, as you would expect).Fixing the problem is dead simple: just delete the
index.htmlfile. Then your routes should kick in as expected.