質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 3.1

Ruby on Rails バージョン3.1.0はRuby on Railsの特定のバージョンです。2011年8月30日にリリースされました。

Q&A

2回答

5213閲覧

localhost:3000/Users/sign_in にアクセス出来ません。

Tomoaki_Fukuda

総合スコア75

Ruby on Rails 3.1

Ruby on Rails バージョン3.1.0はRuby on Railsの特定のバージョンです。2011年8月30日にリリースされました。

0グッド

0クリップ

投稿2016/03/13 09:25

編集2022/01/12 10:55

前提・実現したいこと

Ruby on rails にてサービスのログイン機能機能を作成しております。
Users/sign_inにアクセスする際に、下記のエラーメッセージが表示されてしまいます。
この対処方法を教えて頂けないでしょうか?
※その他不足情報ございましたら、ご教示願います。

エラーメッセージ

Routing Error
uninitialized constant Admin

Rails.root: /Users/TOMOAKI/chinaEC

Application Trace | Framework Trace | Full Trace
Routes

Routes match in priority from top to bottom

Helper HTTP Verb Path Controller#Action
Path / Url
articles_path GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article_path GET /articles/new(.:format) articles#new
edit_article_path GET /articles/:id/edit(.:format) articles#edit
article_path GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
rails_admin_path /admin RailsAdmin::Engine
new_user_session_path GET /users/sign_in(.:format) devise/sessions#new
user_session_path POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session_path GET /users/sign_out(.:format) devise/sessions#destroy
user_password_path POST /users/password(.:format) devise/passwords#create
new_user_password_path GET /users/password/new(.:format) devise/passwords#new
edit_user_password_path GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration_path GET /users/cancel(.:format) devise/registrations#cancel
user_registration_path POST /users(.:format) devise/registrations#create
new_user_registration_path GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration_path GET /users/edit(.:format) devise/registrations#edit
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
root_path GET / admin/base#index
admin_path GET /admin(.:format) admin/base#index
Routes for RailsAdmin::Engine
dashboard_path GET / rails_admin/main#dashboard
index_path GET|POST /:model_name(.:format) rails_admin/main#index
new_path GET|POST /:model_name/new(.:format) rails_admin/main#new
export_path GET|POST /:model_name/export(.:format) rails_admin/main#export
bulk_delete_path POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
bulk_action_path POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
show_path GET /:model_name/:id(.:format) rails_admin/main#show
edit_path GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
delete_path GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
show_in_app_path GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
Request

Parameters:

None
Toggle session dump
Toggle env dump
Response

Headers:

None

Config>locales>routes.rb

ruby

1Rails.application.routes.draw do 2 resources :articles 3 mount RailsAdmin::Engine => '/admin', as: 'rails_admin' 4 devise_for :users 5 6 root 'admin/base#index' # ログイン画面をルートにする 7 get '/admin' => 'admin/base#index' 8 # The priority is based upon order of creation: first created -> highest priority. 9 # See how all your routes lay out with "rake routes". 10 11 # You can have the root of your site routed with "root" 12 # root 'welcome#index' 13 14 # Example of regular route: 15 # get 'products/:id' => 'catalog#view' 16 17 # Example of named route that can be invoked with purchase_url(id: product.id) 18 # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase 19 20 # Example resource route (maps HTTP verbs to controller actions automatically): 21 # resources :products 22 23 # Example resource route with options: 24 # resources :products do 25 # member do 26 # get 'short' 27 # post 'toggle' 28 # end 29 ## Example resource route with sub-resources: 30 # resources :products do 31 # resources :comments, :sales 32 # resource :seller 33 # end 34 35 # Example resource route with more complex sub-resources: 36 # resources :products do 37 # resources :comments 38 # resources :sales do 39 # get 'recent', on: :collection 40 # end 41 # end 42 43 # Example resource route with concerns: 44 # concern :toggleable do 45 # post 'toggle' 46 # end 47 # resources :posts, concerns: :toggleable 48 # resources :photos, concerns: :toggleable 49 50 # Example resource route within a namespace: 51 # namespace :admin do 52 # # Directs /admin/products/* to Admin::ProductsController 53 # # (app/controllers/admin/products_controller.rb) 54 # resources :products 55 # end 56 # end 57 # collection do 58 # get 'sold' 59 # end 60 # end 61

models>concerns>ability.rb

ruby

1class Ability 2 include CanCan::Ability 3 4 def initialize(user) 5 # Define abilities for the passed in user here. For example: 6 # 7 # user ||= User.new # guest user (not logged in) 8 # if user.admin? 9 # can :manage, :all 10 # else 11 # can :read, :all 12 # end 13 # 14 # The first argument to `can` is the action you are giving the user 15 # permission to do. 16 # If you pass :manage it will apply to every action. Other common actions 17 # here are :read, :create, :update and :destroy. 18 # 19 # The second argument is the resource the user can perform the action on. 20 # If you pass :all it will apply to every resource. Otherwise pass a Ruby 21 # class of the resource. 22 # 23 # The third argument is an optional hash of conditions to further filter the 24 # objects. 25 # For example, here the user can only update published articles. 26 # 27 # can :update, Article, :published => true 28 # 29 # See the wiki for details: 30 # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities 31 user ||= User.new # guest user (not logged in) 32 if user.has_role?('admin') 33 can :manage, :all 34 else 35 can :manage, :articles 36end 37 end 38end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

ありがとうございました。

投稿2016/05/02 12:22

Tomoaki_Fukuda

総合スコア75

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

検索したらこんなページありましたけど試してみました?
http://d.hatena.ne.jp/tkrd/20140728/1406511209

投稿2016/03/14 08:17

HiroshiWatanabe

総合スコア2160

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Tomoaki_Fukuda

2016/03/14 12:35

上記は試してみたのですが、ダメでした・・・。 他に何かございませんでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問