The error comes with
Please add some routes in config/routes.rb.
routes.rb already has
devise_for :users
I am not sure how to fix this error. I have tried rake routes in the GIT terminal with the result:
rake aborted!
Don't know how to build task 'routes' (See the list of available tasks with `rake --tasks`)
Running in development mode on local server.
So few things:
Firstly, rake routes has been removed - I have no idea why tbh, but it is rails routes now instead.
Secondly, devise is adding its routes, but you still need to have some ohter content that devise is to guard access to. You can create a simple HomeController:
class HomeController < ApplicationController
def show
render html: "home"
end
end
and use this as your root route:
# routes.rb
devise_for ...
root to: "home#show"
Related
I can't seem to get a matching route in my rspec tests and I am not quite sure why.
routes.rb
resources :admins, only: [:index] do
get 'configs', on: :collection, to: 'admins#configs'
end
Rspec response
Failure/Error: get '/admins/config'
ActionController::RoutingError:
No route matches [GET] "/admins/config"
I run rails routes | grep config and this is the response so I think I am using the correct route
configs_admins GET /admins/configs(.:format) admins#configs
You defined '/admins/configs' (plural) but you're trying to access '/admins/config' (singular).
I have two modular Sinatra rack based applications: core.rb & project.rb:
# core.rb
class Core < Sinatra::Base
get "/" do
"Hello, world!"
end
end
# project.rb
class Project < Sinatra::Base
get "/" do
"A snazzy little Sinatra project I wish to showcase."
end
get "/foo" do
"If you see this, congratulations."
end
end
My goal is simply to map the entire /projects namespace to the Project class, wheras everything else is handled by the Core class. I found that you can do this to a limited extent in 2 ways:
# config.ru
require "./core.rb"
require "./projects.rb"
map "/projects" do
# Method #1: Using Sinatra's built-in Middleware
use Project
# Method #2: Using Rack::Cascade
run Rack::Cascade.new( [Project, Core] )
end
run Core
Both of the methods I tried above have the same effect. The routes / and /projects show up correctly, however when going to /projects/foo it throws an error which states it can't find the /foo route in my main core.rb file - which is NOT what I want. In other words it's looking for my /foo route in the wrong file :(
So, is it possible to map across the entire /projects namespace using rack-mount? And no, adding "/projects/" to all my routes in project.rb is not an option here I'm afraid.
Your config.ru file seems to work okay when I test it, but it looks a little confused. Here’s a simpler example that achieves the same thing:
map "/projects" do
run Project # note run, not use
end
run Core
Now any request where the path starts with /projects will be routed to the Project app, and all other will go to Core, which is associated with the root path automatically.
just playing around with the gem 'gmaps4rails' but I'm getting the following routing error
undefined local variable or method `acts_as_gmappable'
I've performed the following steps:
1) added the following to the Gemfile: gem 'gmaps4rails' and bundled
2) generated scaffold Location
3) added the following to my model, location.rb then db:migrate
class Location < ActiveRecord::Base
attr_accessible :address, :latitude, :longitude
acts_as_gmappable
def gmaps4rails_address
address
end
end
5) changed my root to the following and deleted the old index file
root :to => 'locations#index'
6) added the following to the body of aplication.html.erb
<%= yield :scripts %>
Seems like it can't find the methods in the gem I installed?
I'm using gmaps4rails v2.0.3, ruby v1.9.3, rails 3.2.1
I've looked on similar topics on stackoverflow and performed simple tasks such as restarting server etc but still the same error.
#apneadiving maybe you could help?
Many thanks
Check out the Docs of gmaps4rails, since 2.* version you don't have to add the acts_as_gmappable method.
Now it uses geocoder.
Here is an small tutorial, that explains how it works.
I just migrated a Rails app to 3.1. Active Admin is now 0.6.0. That's my routes.rb
AppName::Application.routes.draw do
root :to => "homepage#index"
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
So root is declared before ActiveAdmin routes. We I start the server in development and I reload the browser I get the ActiveAdmin interface here:
http://localhost:3000/admin
When I reload that URL I get:
uninitialized constant Admin::DashboardController
I found several issues:
assets generator must best execute after an update;
controllers/admin clashes with ActiveAdmin route;
root directive should be define before ActiveAdmin route.
To fix number one:
$> rails generate active_admin:assets
To fix number two:
config.default_namespace = :your_desired_namespace
To fix number three just move root up (in config/routes.rb)
So I'm receiving a routing error No route matches [GET] "/"
my routes.rb:
Webapp::Application.routes.draw do
resources :ideas
end
I scaffolded this ideas controller together by running this in my projects folder:
$ rails generate scaffold idea name:string description:text picture:string
$ rake db:migrate
$ rails s
& thats when I received the routing error.
What do you have for root :to => in routes.rb?
This determines [GET] "/"