ruby on rails web development using heroku - ruby-on-rails

my app is not been uploaded on
heroku
only the first page with welcome to ruby on rails is displayed
my url is
my url link

Your deployed app is presently being overridden by Rails' default static index page. From config/routes.rb:
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
Therefore, first ensure that your root route is set:
# config/routes.rb
root :to => `root_controller#root_action`
Then, delete public/index.html, commit the changes to version control, and redeploy to Heroku.

First make sure you have correct routes. Then you commit the changes to the master branch and then:
git push heroku master
Hope this helps.

Related

Rails app in subdirectory in production not redirecting properly to install shopify store

Using localhost:3000 I was able to install the shopify store and interact with it. However, when deploying it into production, which is in a subdirectory (www.website.com/app_name), the "login" for the shop is redirected to root and not to the subdirectory. I whitelisted the redirect urls in the shopify app dashboard.
In omniauth.rb
callback_url: "http://{domain}/{app_name}/auth/shopify/callback"
In routes.rb
mount ShopifyApp::Engine, at: '/{app_name}'
Apart from the code above, the settings for shopify are the ones that the generator created. Any ideas in how to fix this?
Tanks!
When I did that pattern I had to set the prefix for OmniAuth... in my old config.ru that works for this.. see..
use OmniAuth::Builder do
# allow us to connect this App via the /fooblefuzz route instead of just
the root of the heroku app URL /
configure do |config|
config.path_prefix = '/fooblefuzz/auth'
end
So this code works as https://www.example.com/fooblefuzz/auth/shopify/callback

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]

Rails page not showing in Heroku

I deployed a simple Rails project on Heroku and I'm having some trouble. I set my root page as:
root 'landing#index'
This page works fine when I cd into the project, and start rails server and go to localhost:3000. I pushed to Heroku without error using git push heroku master. However now, if I do heroku open, I get the following message on the page:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
The logs don't show anything significant as well...
Make sure that you have the following:
A LandingController
A view page at the path app/views/landing/index.html.erb
root 'landing#index' on the second line (after Application.routes.draw)
The live repository is up to date
https://devcenter.heroku.com/articles/getting-started-with-rails4#write-your-app
Failing that, run heroku run rake routes. You should see a route like GET /landing/index landing#index and root / landing#index
If they don't appear, add the line resources :landing to generate the default routes for the landing controller.

Ruby on Rails only showing what is in public folder

I am new to rails and have developed a simple rails application on my machine that works when hosted locally with WEBrick.
I understand that you need to delete index.html from the public folder and set the proper root in config/routes.rb to point to the controller you wish to be root, which I did with:
root :to => 'home#index'
(On the remote host)
When I have the index.html file in the public folder and go to mywebsite.com/myapp I see the page.
When I delete the index.html page from the public folder I get a 404 and my app does not run.
Any idea as to why my app is not running when I deploy it to the remote host?
If you set your root to home#index, then you need to have a view app/views/home/index.html.erb. The corresponding controller method would be def index, located in app/controllers/home_controller.rb.

heroku doesnt show my views. RoR project

So I am trying to upload a RoR project I am working on. So to make it more interesting I just changed the home page, instead of having the usual one. I deleted the public/index.html, created a static page controller and added a new home.html.erb file in my views folder. I also changed the config/routes file. It works fine on my localhost. then I run these
git add .
git commit -m "Added home page"
git push heroku master
heroku run rake db:migrate
heroku open
and for a homepage I get the usual RoR page instead of mine. What did I do wrong?
Try deleting public/index.html as that is probably getting served before hitting the app.

Resources