Rails missing route - ruby-on-rails

So I have a website for a class. I am creating a login for the website, so I start with
"rails generate scaffold User name:string password:digest --no-test-framework" to create the model.
I ran "rake db:migrate" to create the database.
I ran the rails server and opened chrome to check the webpage out by entering the url "localhost:3xxx/users/new" and I get a Routing error that says "No route matches [GET] "/users/new"
I did a "rake routes" to check it out and it is correct, there is no route to "/users/new".
When I ran the generate scaffold I noticed that it did say that it created the route but its not showing up!
Am I missing something?

Nevermind, I manually added get "user/new" => "users#new" to the routes.rb file and it worked!
I'm new to rails and usually whenever I use generate scaffold I never get this problem.
If anyone knows how or why the route wasn't added when I used the generate scaffold, please let me know for future reference, thanks!

Related

Rails demo app on local host not working

New to Rails. Everything solid through creation of demo_app, but rails server is yielding just the basic rails welcome page, not my demo application
You need to delete public/index.html and change root to: in config/routes.rb to point to your welcome page's controller action.
Well, then Rails works :)
In your console cd to the Folder where your rails app is and run
rake routes
Then try out one of the routes in your browser.
If there aren't any, you have to create routes. Follow some tutorial for this.

Rails 3.2.8 Routing Error

Started learning Rails a couple of hours back using the book Agile Web Development with Rails and hit a roadblock straightaway.
Created a controller called Say using:
rails generate controller Say hello goodbye
Then I was trying to hit the URL http://localhost:3000/Say/hello but it says:
No route matches [GET] "/Say/hello"
My routes.rb looks alright too (at least from what the other answers on the same question say):
Demo::Application.routes.draw do
get "say/hello"
get "say/goodbye"
end
Any help? Just not able to figure this out.
Looks like a capitalization error. Can you go to
http://localhost:3000/say/hello
Lowercase s in say
It's case-sensitive.
Try to reach it at http://localhost:3000/say/hello

Rails Server, new files not live

I'm going through a Ruby on Rails tutorial and right now it's generating controllers. (I believe I'm on the local server.. started by doing:
$rails s
When I look in TextMate, all the new files have a "no entry" sign on them, which I assume to be not live. They also don't work when I try to pull up the address.
How do I make them live?
(Edit: Picture added, also.. When I try to go to the page it says:
Routing Error
No route matches [GET] "address"
Try running rake routes for more information on available routes.
Rails should not be generating controllers.
My advise is to start all over
rails new myApp
cd myApp
rails generate scaffold Post name:string title:string content:text
rake db:migrate
rails s
At point your browser to http://localhost:3000
Then you'll see the rails welcome page
If you point the browser to http://localhost:3000/posts you'll get to the post index page
And read this rails guide
update
Are you running rails generations from another user? It looks like you don't have read and write rights to the files from textmate.
Embarrassing lesson. The server was attached to a different directory. And apparently the symbol isn't read/write.. Not sure what it is though

Trying to learn RoR, but keep getting Page doesn't exist errors

I'm trying to learn RoR and I keep getting pesky page doesn't exist pages. I deleted the index.html file out of my public folder and created a root route in my routes file but I still am getting that error. I am running ubuntu 10.04 with mod_passenger and ruby enterprise edition.
just leave the mod_passenger until you find the error. Do like this:
open a shell
go to your Rails app directory
ruby script/server (Rails < 3).
It should start the server in your console. and browse the page you want. If you are getting an error it should display in the console.
check your database connection is OK in config/database.yml file
rake routes is the standard shell command to see all your routes. Check if url you're trying to access is in the list. If it's not, show us statement in routes.rb you use to generate this route and url you're trying to access.
Can you please paste the content of your routes.rb file?
Also, make sure you have a controller created for that page and it should contain the index action.
def index
end

Routes not resolving in Production Environment (Rails 2.3.5)

I'm deploying my app to a live server running passenger on Apache. I've tested the app locally and my routes appear sound. I have my public controllers under app/controllers/content and my admin controllers under app/controllers/admin.
Despite everything working in the development environment i'm getting "The page you were looking for doesn't exist." error when I request http://mydomain.com/content/compare. (i.e. Content::CompareController#index).
My production log contains the lines:
Processing ContentController#compare (for 86.40.236.34 at 2010-08-14 15:03:15) [GET]
Authentication: session found, user_id is set
ActionController::UnknownAction (No action responded to compare. Actions: ):
I've called rs.recognize_path 'content/compare' and I get the error:
ActionController::RoutingError: No route matches "content/compare" with {}
The same command works with my development machine however. I've tried adding the line
map.connect 'content/:controller/:action' to the routes config file but this doesn't have any effect and I don't think it would be useful in the long run either.
Any advice on this? Seems strange that there are inconsistences between the Rails Environments.
Thanks in advance for any help,
Can we see your routes.rb file?
It appears that on your production machine it is trying to call the compare method in ContentController. Is this the method you want to be calling or is it index?
My guess is there is something wrong in your routes file. You can compare it on both environments by running rake routes.

Resources