When navigating to localhost:3000, I want to navigate to: localhost:3000/workers.
So I changed public/index.html to public/index.html.bak and in routes.rb, I defined the next followings:
devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end
resources :tasksadmins
resources :workers
root to: "workers#index"
However, it doesn't work. The page localhost:3000 shows me the Welcome aboard page.
How can I fix it? Any help appreciated.
Seems fine. Have you restarted the server?
Related
I am developing a rails app and This is my first time working with ruby or any server-side programming language. I connected to localhost:3000 and everything went well. I went to change the routing for my home page as well as create some new ones but I'm having an issue of gettign them to preview and I keep Getting error messages. Here is the snippet from my routes.rb file
My routes.rb
Rails.application.routes.draw do
root 'pages#home'
get 'about' => 'pages#about'
post 'forum' => 'pages#forum'
get 'contact-us' => 'pages#contact-us'
end
I'm still relatively new To programming as well as stack overflow so I can't embed images yet So it will only have a link. Any help would be appreciated. Thank you!
1 - Try to avoid fat arrow
2- Controller name should not contain -(dash) instead use _(Underscore) example(contact-us should be contact_us)
Rails.application.routes.draw do
root 'pages#home'
get '/about', to: 'pages#about', as: :about
post '/forum', to: 'pages#forum', as: :forum
get '/contact_us', to: 'pages#contact_us', as: :contact_us
end
3- After changing this run rake routes at your console in your project directory , you will get list of routes
4- you can now use routes helper of prefix_path example (root_path, about_path or forum_path, contact_path)
Hi I'm trying to deploy an app made with help of "Agile web development by S.Ruby" and I always get the same error - The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
I've already tried to migrate my DB on Heroku - that wasn't the case.I think something is wrong with routes.rb file, but I can't understand what is incorrect exactly,please help me to solve this problem
Here is my routes.rb file:
Depot::Application.routes.draw do
get 'admin' => 'admin#index'
controller :sessions do
get 'login' => :new
post 'login' => :create
delete 'logout' => :destroy
end
get "sessions/create"
get "sessions/destroy"
resources :users
resources :products do
get :who_bought, on: :member
end
scope '(:locale)' do
resources :orders
resources :line_items
resources :carts
root 'store#index', as: 'store', via: :all
end
end
As Michal correctly points out you miss the root path. You have defined a route inside the scope you use to get to the different locales, but not a global root. This is not a Heroku problem, it won't work on your local server either.
So, http://your_server.com/en will work, but http://your_server.com will not.
You need to add a root path outside all scopes, like so:
root 'store#index'
You will have to set a default locale or something like that. You can leave the other root directive inside the scope, as you have named it explicitly (with as: 'store') there won't be any conflict.
I'm new to rails and I'm using devise to authenticate users.
I have a devise User model and I'm using devise views.
my routes.rb file goes like this
Freshconnection::Application.routes.draw do
root to: 'pages#home'
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
devise_for :users do
ActiveAdmin.routes(self)
get '/users/sign_out' => 'devise/sessions#destroy'
end
As of now when I run the server, the request is routed to pages#home which is my landing page.
I want the users/sign_up page to be the landing page so that the user can sign_up and start using the website.
Please guide me on how this has to be accomplished.
Many thx
As described here (link) you could try the workaround
devise_scope :user do
root to: "devise/registrations#new"
end
Change your root directive to:
root to: 'devise/registrations#new'
I'm new to ruby on rails, and I'm having trouble getting up to speed. I've set up devise for user authentication, and everything seemed to be going well. Until I tried to get routes set up
Basically, I've deleted my /public/index.html, and I've set a new default route. Here's my /config/routes.rb
MyApp::Application.routes.draw do
authenticated :user do
root :to => 'home#index'
end
root :to => "home#index"
devise_for :users
end
Okay, so that seems simple enough. I generated a home controller/view. My index.html.erb is just the default. My controller is also blank.
When I run rake routes, I can see the route to the root.
root / home#index
root / home#index
So this seems like a go! But...It's not. I get an error when I try and open my index
No route matches [GET] "/"
I don't feel like the details of my server should be significant, but it's nginx. I can post my server configuration if anyone thinks it's important.
Blargh. I'm an idiot. The server configuration I though wouldn't matter was the problem. I had edited my nginx settings, but I left the default in Unicorn. I never noticed before now, since the /public/index.html in both the unnecessary app and my app were the same. Thanks for all the help though.
You should be add resources :homes
MyApp::Application.routes.draw do
resources :homes
root :to => "home#index"
devise_for :users
end
For my rails 3 app I have a route setup as follows
namespace :user do
root :to => "reading_schedules#index"
end
This is what my "rake routes" shows
user_root /user(.:format) {:controller=>"user/reading_schedules", :action=> "index }
Everything works fine on my localmachine. But as soon as I push the site up to Heroku and login I get the following error in my logs
ActionController::RoutingError (uninitialized constant User::ReadingSchedulesController):
If I navigate to the root of the site everything else works fine. But this one url doesn't work. The url it's trying to hit is website/user but like I said, it works fine on my localmachine.
EDIT:
Here's the rest of my routes file
devise_for :users, :path => 'accounts'
root :to => "home#landing"
namespace :user do
root :to => "reading_schedules#index"
end
resources :users do
resources :reading_schedules
member do
get :change_password
post :change_password
end
end
resources :reading_schedules do
member do
get :recalculate
end
end
I found this question first in looking for an answer to the same issue. For any future searchers, check out this link.
For me, it was a combination of the last two answers in this post (adapted for my controllers of course.)
Also of note, this corrected the issue without having to reset the database.
ActionController::RoutingError (uninitialized constant User::UsersController) in heroku (but everything works in local)
Probably not the answer you are looking for but
heroku rake db:reset
solved the problem for me. I didn't have any critical data in the
db so it was not a problem.