Rails 3.2.8 Routing Error - ruby-on-rails

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

Related

Routing error on ch 2 micropost rails tutorial (routing_error.html.erb within rescues/layout)

I'm working on the micropost toy_app in Chapter 2 of the Ruby on Rails Tutorial, and my site on the cloud9 url (http://rails-tutorial-[username].c9users.io/microposts/new) isn't working. I've tried a bunch of things to try to fix this (eg, ctrl c, starting rails server over, ctrl c again, pushing possible changes I missed to heroku etc), but the displayed web page toggles between the red and white "we're sorry but something went wrong" generic error and the blue/pink floral "No application seems to be running here! Cloud9 can't get you to your requested workspace" errors.
In the C9 dev logs show these two error over and over:
Rendered /usr/local/rvm/gems/ruby-2.2.1/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates/rescues/routing_error.html.erb within rescues/layout
and
ActionController::RoutingError (uninitialized constant MicropostsController)
I've searched all over and it looks like most people with routing errors have different errors messages, and it's because they haven't defined their routes properly. I'm totally new to this, and I can't figure out what I'm doing wrong.
Previously (when I went through chapter 1 of the tutorial), my /users and /users/new pages worked, however now none of those URLs work either. Would this be related to a C9<>bitbucket<>heroku issue, or is it likely to be with my actual code? heroku logs didn't show anything meaningful.
My routes.rb file looks like this:
Rails.application.routes.draw do
resources :microposts
resources :users
root 'microposts#index'
end
For what it's worth, I started the tutorial on 12/25/15, which is the day that rails 2.3 was released-- however my logs show I'm on 2.2.1. I wonder if during the 20-30 hours since I started on 12/25, my rails version on c9 got outdated? I don't understand how that works since I'm using a cloud IDE.
I'm brand new to rails and haven't done any programming aside from a few classes in college-- any tips or pointers would be appreciated.
After starting over, I finally figured it out after another hour or so-- I had 2 problems. The first was that I'd only run one of the 2 necessary scaffolding commands in the tutorial (doh!). I discovered this by more carefully reading the c9 development log, and noticed a line that said ActionController::RoutingError (No route matches [GET] "/micropost"):. at this point I realized I was missing the micropost application controller, because I'd never created it with the 2nd scaffolding command: rails generate scaffold Micropost content:text user_id:integer
The other problem is that I didn't (and still don't) really understand how the rails server works-- so I was making my changes and not realizing that the server needed to be actively running for the website to load. When I run the rails server -b $IP -p $PORT command, it looks like it never finishes (eg, the $ for me to start my next command prompt never appears until I hit ctrl c). So I kept hitting ctrl c, not realizing I was killing the server that was hosting the web page.
What I did now was make all my changes, then run the server, then hit ctrl c when I need to make more changes.
Am I doing something wrong with the server stuff? Overall it's working, but it seems like there could be a better way.

No route matches on Rails

I have installed one of my RoR app on my local computer from GitHub.
And trying to have it running on my local machine
But after successful login they throwing me this error which drives me crazy.
I tried to find out solutions, but failed.
Can u guys please explain me possible reasons for this error?
Thanks.
No Route Matches basically means you're trying to load a URL / Route which doesn't exist in your config/routes.rb file
To fix it, you have to look at the request you've sent to Rails & see if it's matched within the routes file. If not, ActionDispatch::Routing will not be able to direct your request to the correct controller / action
You need to give us the actual error & show the routes.rb file to get an accurate answer

Blogit is not routing in rails 4

Hi guys,
I have just installed blogit into my Rails 4 application. When I go to /blog I get routing error of every single route I have got. I get "undefined local variable or method". It is like that it won't load my routes at all.
Not sure if it make sense though. Please let me know what you want me to put here so you guys can have a look.
I have current_user defined in ApplicationController.
In the installation what I didn't understand is "declare which of your models acts as blogger in your app". That might be the issue.
Thanks in advance.
In case someone is looking for this.
Answer trail is in here. It is Explained fully
So just to sum it up, I added main_app to all of the links in the view and all are good.
Basically when you are in the /blog you will be in the engine, and you need to tell the app the correct path. Thanks to emaxon.

Ruby on Rails routing problem

The company that hosts my website did an upgrade on the weekend and now all my ROR apps are coming up with this :
Routing Error
No route matches "/geotest/" with {:method=>:get}
These were working before and do work on my development system, but there has been no response to my ticket to their tech support. Anyone got a suggestion how I could fix this?
Maybe they upgraded to Rails 3 ? Your route should work anyway, but try to add this to your routes.rb file :
get '/geotest' => 'your_controller_name#index'
Change your_controller_name accordingly, of course.

Rails Routes Question

Did the rules for Rails Routes changes from Rails 1.2.3 to Rails 2.2.3? I recently upgraded an application and instead of redirecting to the correct page, it now redirects to the main page (or Route page) for that matter.
The only thing that I can think of is that the routing rules changed in Rails 2.2.3.
Thanks
Yep there were a lot of changes as you can see here (look at the Action Pack Resources section) "This is where the bulk of the action for 2.0 has gone". If you're using the old semi-colon syntax then that could well be the problem. Do you want to post your route config and a quick description of what is not working?
Also, to diagnose routing problems I find running "rake routes" very useful (though set your terminal window to wide).
Chris

Resources