No route matches on Rails - ruby-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

Related

Heroku app page not found

I deployed a rails app on Heroku. Everything was working fine. I pushed the code to Heroku master, and everything worked as expected. I also ran Heroku run rails db:migrate. No errors were thrown. I can even run the Heroku run rails console, and create objects, no problem. However, It does tell me that I have to type in User.connection, (Users are the only models I have in the app right now). When I type Heroku config I get expected output. Everything seems perfect. But, when I open the app, it says that the page is not found:
No webpage was found for the web address: https://my-api.herokuapp.com/
It's probably worth mentioning that It's a rails API, therefore, there are no views, and no root page. But despite that, I still don't get any responses when I make API calls with Postman. I simply get a 404 response. I would at least imagine that HTTP requests would work, but they don't. Any idea why?
Upon loading the app the logs say
ActionController::RoutingError (No route matches [GET] "/"):
does mean there is no root route? I thought for an API, there didn't need to be one?
ActionController::RoutingError (No route matches [GET] "/"):
It means that it is pointing to your app and search for root route but if that isn't defined in the routes file then it will show this error.
For API mode only means that it will not generate css and coffee files related to controllers.
Open App links to app and finds the root path and if it doesn't find then it this error occur.
Since you are using API mode thus this error will not be troublesome.
Check your routes.
Heroku can return such an answer when you just have no a root route.
If you have any specific routes you can try to go it and application will work.
https://my-api.herokuapp.com/return_mystuff

'Cannot GET' error while following RubyOnRails Tutorial

While following the Ruby on Rails Tutorial I successfully git push heroku master. However I don't get the same output as the author - he sees the same "hello world" text that I see in my c9 environment. But I only get the following error:
Cannot GET /devonparsons/rails-tutorialasdofne.herokuapp.com?_c9_id=livepreview1&_c9_host=https://ide.c9.io
Due to the vague naming of this error it's kind of hard to troubleshoot. As far as I can tell by googling, Cannot GET is a result of there not being anything TO get. This question states the problem might be with your .gitignore file, so I tried commenting out some lines there, but it did not help.
I noticed that it the error string is mashing my 'random' subdomain (asdofne) against "rails-tutorial", which looks wrong, but I don't know what it means.
How do I fix this error?
I have gone through your heroku logs result and noticed that URL of your heroku application doesn't append with http://.
You need to append your heroku app url asdofne.herokuapp.com with http://
Results https://asdofne.herokuapp.com
The link looks funny. I remember that this happens when I create an HTML link and then forget to prepend it with http://. Could it be that something like that happened? It looks like it's taking a, what's supposed to be absolute url, and turning it into a relative one.

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.

Redmine 404 on some pages

I have installed Redmine on a shared Bluehost account and at first sight it seems to be working.
I followed both of these tutorials: https://my.bluehost.com/cgi/help/redmine and http://www.redmine.org/projects/redmine/wiki/RedmineInstall
But just as i started navigating around i noticed that there seem to be a routing problem because some of the pages are returning a 404 error code for a reason i don't understand yet.
The error log shows no information regarding this problem.
The url is on redmine.example.com , the user/pass are still admin/admin.
I have identified that any URL regarding a project is failing, for example:
http://redmine.example.com/projects/new
http://redmine.example.com/projects/21
http://redmine.example.com/projects/21/issues
(Currently i have reset the DB for privacy concerns)
In order to prove my theory that it was regarding the projects issue, i went into the projects controller file found in app/controllers/projects_controller.rb and tried to put some abort("Foo") here and there but i couldn't see my message with any of the links that are not working so i thought maybe the problem is not there and is probably in the routing process. So i checked the config/routes.rb file and comparing it with my local version they seem identical
I am not sure what to try next as i am not a Ruby developer. Let me know what kind of info you need in order to help debug this problem.
Eventually i got it working by using FastCGI.
In order to do that, i simply created a .htaccess file and a dispatcher.fcgi as shown in the answer here : Redmine 2 on Hostmonster apache fcgi: Rails application failed to start properly
Don't forget to SetEnv GEM_PATH to your ruby gems path in your .htaccess file and it should work after restarting (pkill dispatcher.fcgi)

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

Resources