getting error while creating Web services with Ruby on Rails - ruby-on-rails

Getting error while creating webservices on Ruby on Rails.
I have followed what ever the steps mentioned in this.
After starting the Server with rails server command, when I am hitting http://localhost:3000/hello_message/wsdl, it's giving me the error:
ActionController::RoutingError (No route matches [GET] /hello
message/wsdl)
routes.rb:
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

That tutorial is from 2008, I'm not quite sure but maybe this could help you to fix it
Add resources :hello_messages
or
get '/hello_messages/wsdl' => 'hello_messages#hello_messages'
This should be inside of Rails.application.routes.draw do
But I'll recommend you to look for more recent tutorials

Related

ActionController::RoutingError (No route matches [GET] "/serviceworker.js"):

Installed Rails 6.0.3. Ran rails new [app], started the server, loaded the homepage and the server logs are showing this routing error. Any ideas? Here's my routes file which I haven't touched.
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
Going into Chrome's Dev Tools > Application > Clear Storage fixed my issue.
If you want to use the service-worker in the rails, please refer to as follows
https://github.com/rossta/serviceworker-rails

Rails Tutorial sample_app fails in Heroku with log: ActionController::RoutingError (No route matches [GET] "/about"):

I am following the online version of Rails Tutorial. The Sample_app in chapter 3 works fine locally, but when pushed to Heroku, the home page is found but not the other pages. Running heroku logs after trying to see the About page gives me (along with much else) the error above:
2015-08-09T02:56:43.916991+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/about"):
My routes.rb file is
Rails.application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
get 'static_pages/about'
end
I have followed the directions carefully. I tried deleting and recreating the Heroku file. I did web searches and tried some things to no avail. My gemfile is straight from the online version of the book, which is using current versions.
Solved: #thedanotto had me run heroku run rake routes which showed that the help and about pages were directed to {root}/static_pages/about rather than {root}/about. I am still puzzled why the tutorial gives the about routes, which appear not to work as expected, and welcome any further comment, but I am marking this as solved.
Whenever I can't find a route, I run the terminal command
rake routes
Since you're on heroku you'll want to run
heroku run rake routes
Which will return something similar to the following.
Prefix Verb URI Pattern Controller#Action
static_pages_about GET /static_pages/about(.:format) static_pages#about
So that shows that you can go to www.[heroku_app_name].herokuapp.com/static_pages/about And it will bring you to the page you want. You can also add a link to the page in a view by putting the following line of code within a view.
<%= link_to("About", static_pages_about_path) %>
That's all good stuff to know. But let's talk about using the controller action: static_pages#about with the path /about
Switch the following in routes.rb from
get 'static_pages/about'
to
get "static_pages/about", path:"/about"
or alternatively
get "/about", to: "rabbits#about"
You can read more about Routes here
If it works fine locally, I assume you've set up the controllers, views etc properly.
Have you made sure to commit all those necessary changes then push?
e.g.
git add .
git commit -am "Added route"
git push heroku master
Are you accessing the about page using the following URL ?
http://YourHerokuAppName.herokuapp.com/static_pages/about
[ Replace "YourHerokuAppName" with your Heroku App Name]

Routing Issues Trying to Upload a File in Rails

I'm trying to learn how to upload a data file to an application by following the instructions http://bit.ly/JgJyV and http://bit.ly/LXZ44L.
After following the instructions and typing in the code I open my browser and go to the link below.
localhost URL on port 3000: .../upload/index
Routing Error
No route matches [GET] "/upload/index"
Try running rake routes for more information on available routes.
I update config/routes.rb with:
resources: upload
Revisit localhost URL on port 3000: .../upload/index
Unknown action
The action 'show' could not be found for UploadController
Try localhost URL on port 3000: .../upload
Works! I select a file and click the Upload button:
Routing Error
No route matches [POST] "/assets"
rake routes returns:
Steves-iMac:config steve$ rake routes
upload_index GET /upload(.:format) upload#index
POST /upload(.:format) upload#create
new_upload GET /upload/new(.:format) upload#new
edit_upload GET /upload/:id/edit(.:format) upload#edit
upload GET /upload/:id(.:format) upload#show
PUT /upload/:id(.:format) upload#update
DELETE /upload/:id(.:format) upload#destroy
Any ideas?
There are widely used ruby gems to do what you want to do: Paperclip and Carrierwave.
So, why reinvent the wheel?

Ruby on Rails index.html.erb not loading

Just starting in Rails and I'm trying to get my index.html.erb page to show when I enter my rails-backend sub-domain.
I've been following the instructions from this guide but have run into some trouble. Searching google and SO for an answer did not yield results, so here I am.
I ran $ rails generate controller home index in order to generate index.html.erb, and deleted public/index.html as well. I then went to the routes.rb file in the /config directory and added this line:
root :to => 'home#index'
I also removed this line:
get "home/index"
My index.html.erb in the app/views/home/ directory looks like this:
<h1>Hello Rails, my best friend!</h1>
<p>Find me in app/views/home/index.html.erb</p>
<br />
<p>Also word to your mother</p>
I ran rake routes in the terminal and got this output:
(in var/www/testapp)
root / home#index
When I try to go to my sub-domain I get the following page:
I then tried uncommenting the get "home/index" line in routes.rb, but the same result showed up. Here is my home_controller.rb file, which I didn't touch but a) the guide didn't ask me to and b) looks normal compared to other controllers I've seen:
class HomeController < ApplicationController
def index
end
end
I'm sure this is a simple question, but I couldn't find any questions with a similar situation on SO. Thanks for helping!
Your code all looks correct. I would recommend foregoing Passenger and use the Thin server instead. It handles both http and https.
It's as simple as this:
Add the following line to your Gemfile: gem 'thin'
Install the gem: bundle
Start the server: bundle exec thin start --ssl
This way, you receive the benefits of the Mongrel parser and SSL without needing any custom Apache configuration.

Resque-web path not working

I just upgraded to rails 3.1 and is getting a weird routing problem with resque-web
I've mounted resque-web on my routing.rb like this:
mount Resque::Server, :at => "/resque"
when my server is up going to 0.0.0.0:5000/resque works fine but declaring the path 'resque_path' in my erb.html files gives me
undefined local variable or method `resque_path' for #<#<Class:0x000001038e9eb0>:0x000001038a7650>
it's even listed on my rake routes as:
resque_server /resque {:to=>Resque::Server}
'resque_path' should be working! i hav no idea why it is now. anyone?
If you check rake routes you can see that solution is:
resque_web_path
Have you tried resque_server_path? That could do it.

Resources