-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined method `destroy_user_session_path' for #4220
Comments
did you have installed and setup devise? Please post you routes.rb and user model |
I am not using devise , I am using Cancancan and sorcery here is routes.rb Rails.application.routes.draw do
ActiveAdmin.routes(self)
get 'projects/index'
resources :password_resets, only: [:new, :create, :edit, :update]
resources :domains, only: [:index, :create, :edit, :update, :destroy]
resources :projects, only: [:index, :create, :edit, :update, :destroy]
resources :tasks, only: [:index, :create, :edit, :update, :destroy]
resources :fact_pages, only: [:index, :create, :edit, :update, :destroy]
resources :task_types, only: [:index, :create, :edit, :update, :destroy]
namespace :reports do
get 'all'
get 'production'
get 'non_production'
get 'daily_reports'
end
resources :activities, only: [:create, :edit, :update, :destroy] do
collection do
post :start
get :stop
get :export
end
end
root to: 'dashboard#index'
resources :users do
collection do
get :export
end
member do
get :activate
patch :confirm_activate
end
end
resources :dashboard, only: [:index]
resources :user_sessions, only: [:new, :create, :destroy]
end
and user.rb
equire 'model_sync'
class User < ActiveRecord::Base
include ::ModelSync
paginates_per 50
authenticates_with_sorcery!
acts_as_paranoid
enum status: { Active: 0, Terminated: 1, Resigned: 2 }
enum level: { Admin: 0, Regular: 1, Client: 2 }
enum contributor: { Data_Entry_Contributor: 0, Judgment_Contributor: 1, Contributor_Lead: 2 }
enum shift: { Day: 0, Night: 1 }
has_many :activities
has_many :domains
has_many :fact_pages
has_many :tasks
has_many :task_types
has_many :projects
validates :email, presence: true, uniqueness: true, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
validates :first_name, presence: true
validates :last_name, presence: true
validates :status, presence: true
validates :level, presence: true
validates :contributor, presence: true
before_create :setup_activation
after_create :send_activation_needed_email!
def self.to_csv(options={})
CSV.generate(options) do |csv|
csv << column_names_except_password_fields
all.each do |user|
csv << csv_output_row(user)
end
end
end
def self.column_names_except_password_fields
column_names - ['crypted_password', 'remember_me_token', 'remember_me_token_expires_at', 'reset_password_token', 'reset_password_token_expires_at', 'reset_password_email_sent_at', 'salt', 'deleted_at']
end
def self.csv_output_row(row)
column_names_except_password_fields.map do |field|
# Necessary to return enum strings instead of enum integers
row.public_send(field)
end
end
def current_activity
self.activities.find_by("start_time IS NOT NULL AND end_time IS NULL")
end
def to_s
full_name
end
def full_name
"#{first_name} #{last_name}"
end
def active?
status == 'Active'
end
def staff?
(admin? || client?) && active?
end
def admin?
level == 'Admin' && active?
end
def client?
level == 'Client' && active?
end
def sum_of_durations_for_date(activities, date)
duration_in_secs = activities.where("end_time >= ? and end_time <= ?", date.to_time, (date.to_date + 1).to_time).inject(0.0) { |res, activity| res += activity.duration }
(duration_in_secs/3600).round(2)
end
def production_duration_for_date(date)
self.sum_of_durations_for_date(activities.production, date)
end
def non_production_duration_for_date(date)
sum_of_durations_for_date(activities.non_production, date)
end
def total_hours_for_date(date)
(production_duration_for_date(date) + non_production_duration_for_date(date)).round(2)
end
end |
authenticates_with_sorcery! does this uses devise? |
No it doesnt , its using sorcery gem , is it a must to use devise ? I am using sorcery and Cancancan |
seems you are missing devise_for :admin_users, ActiveAdmin::Devise.config |
so does that mean i have to gem install devise , i will end up having to authentication gems .. is that possible , my authentication gem for now is sorcery and not devise Question: Is it a MUST to have devise installed ? i am guessing now Or should I just add that line up there in routes ? |
yes it is must to have devise installed. Because activeadmimn uses devise for authentication. |
thanks and can i have devise and sorcery side by side ? sorcery to authenticate in my app and devise for active admin ? then cancan adapter for authorization |
yes, as they works as expected. |
ok thanks a lot !! let me give it a shot .... in case i am stuck i will give you a shout |
Thanks, I can hear that!! 😄 |
@wolfieorama you don't need to use devise! |
@timoschilling so whats my way out ? |
@wolfieorama If you don't use devise, you need to set |
ok , that sounds better that running 2 auth gems ..... do you a guide example on how to create that .. sample may or a quick guide :) |
How do you lock out with sorcery? |
you mean logout ? |
this is the route: user_session DELETE /user_sessions/:id(.:format) user_sessions#destroy def destroy
authorize! :log_out, User
logout
redirect_to root_url
end this is in user_session_controller.rb |
then you need to use |
same error: :ActiveAdmin::Views::TabbedNavigation config.logout_link_method = :destroy or :delete - i have tried both |
sorry |
draaaaat !! how did i not see that ..... sleepy eye :).... a bit of progress new error : No route matches {:action=>"destroy", :controller=>"user_sessions"} missing required keys: [:id] should i include the :id in params ... i dont think so |
@wolfieorama please read this for future comments https://help.github.com/articles/github-flavored-markdown/#syntax-highlighting |
got you .. my bad @timoschilling thanks |
ActiveAdmin don't support urls with ids at logout path at the moment. |
oh no ....any workarounds possible ?.... or does that mean i use devise for activeadmin authentication and sorcery for the rails app ? |
@timoschilling is it ok to use the 2 gems side by side ? it doesnt feel good to me .... but might give it a try |
You can refactor your sign out action to work with the current_user instead of the user id. |
But yes, working with 2 gems is ok, but is not necessary. |
i would go with the first option ..... thanks a lot any example available using either methods ? |
you can say active admin to link to |
👍 |
@railsfactory-bhaskararao on your suggested method above where i have to use both devise and sorcery i have successfully managed to load the activeadmin page but on signing in i get and error:
i then went ahead and created the method in admin_user.rb def admin?
@admin = AdminUser
end
def active?
@active = AdminUser
end this now leads to another error:
any tips , also i am wonderin in application controller can i have check authorization unless: for both devise controller and activeadmin resource thanks in advance |
I have installed activeadmin but when i navigate to the localhost:3000/admin i get an erro of a missing method, where should this be defined
undefined method `destroy_user_session_path' for
<ul class="header-item tabs" id="utility_nav"></ul> :ActiveAdmin::Views::TabbedNavigation
here is my activeadmin.rb
Help please
The text was updated successfully, but these errors were encountered: