2016-03-24 5 views
1

Ich habe eine Herausforderung Aufspüren ein Update für den folgenden zerstören:Unable Session-Objekt in Heroku

  • Ich bin in der Lage Login/Logout in meiner Entwicklungsumgebung

  • Ich bin nicht in der Lage in meiner Produktionsumgebung

ich habe sah und versuchte Lösungen auf folgende Fragen abzumelden:

Ich bemerke, SQL in Heroku logs sagt Ausgewählte Mitarbeiter, wo deleted_at Null ist, andernfalls nur eine GET-Anforderung an Sitzungen zu sehen #neu, wenn ich auf "Abmelden" klicke.

Heroku logs --tail

Hier ist mein Code:

sessions_controller.rb

class SessionsController < ApplicationController 
    skip_before_action :require_login, except: [:destroy] 

    def new 
    @employee = Employee.new 
    end 

    def create 
    if @employee = login(params[:email], params[:password]) 
     flash[:success] = "You're logged in!" 
     redirect_back_or_to(root_path) 
    else 
     @employee = Employee.new 
     flash.now[:notice] = "Login failed." 
     render :new 
    end 
    end 

    def destroy 
    logout 
    flash.now[:notice] = "You have successfully logged out." 
    redirect_to(root_path) 
    end 
end 

_nav.html.erb

<li> 
    <% if current_employee.present? %> 
    <% if current_employee.is_admin %> 
     <h5 style="margin-top: 5%;"> 
     Logged in as <strong><em><%= current_employee.email %></em></strong> 
     <%= link_to('Edit Account', edit_account_path(current_employee.account_id), class: "text-normal") %> 
     - or - 
     <%= link_to('Logout', logout_path, options = { method: :delete, class: "text-normal" }) %> 
     </h5> 
    <% elsif current_employee.is_admin == false %> 
     <h5 style="margin-top: 5%;"> 
     Logged in as <strong><em><%= current_employee.email %></em></strong> 
     <%= link_to('Edit Profile', edit_employee_path(current_employee), class: "text-normal") %> 
     - or - 
     <%= link_to('Logout', logout_path, options = { method: :delete, class: 'text-normal' }) %> 
     </h5> 
    <% end %> 
    <% else %> 
    <h5 style="margin-top: 9.5%;"> 
     &nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;&nbsp; 
     <%= link_to('Login', login_path, id: "employee_login", class: "text-normal") %> 
     - or - 
     <%= link_to('Register Today!', new_account_path, id:"admin_registration", class: "text-normal") %> 
    </h5> 
    <% end %>  
</li> 

routes.rb

Rails.application.routes.draw do 
    root to: "static_pages#home" 

    get "static_pages/about", to: "static_pages#about", as: :about 
    get "static_pages/pricing", to: "static_pages#pricing", as: :pricing 
    get "static_pages/contact", to: "static_pages#contact", as: :contact 

    get "sessions", to: "sessions#new", as: :login 
    post "sessions", to: "sessions#create" 
    delete "sessions", to: "sessions#destroy", as: :logout 
    resources :employees 
end 

config/production.rb (hinzugefügt diese configs)

Rails.application.configure do 
    config.cache_classes = true 
    config.assets.compile = true 
    config.assets.digest = true 
end 

Vielen Dank im Voraus für einen frischen Satz Augen freiwillig!

Antwort

0

Es stellte sich heraus, dass ich dieses Problem mit einem anderen Problem behoben.

Ich habe config.action_controller.asset_host = "http://www.name_of_site.com" von production.rb entfernt, um meine Vermögenswerte in der Produktion arbeiten zu lassen.

Ich bin mir nicht sicher warum, aber dies hat auch das Problem behoben, dass ich mich nicht auf Heroku abmelden konnte.

Ich postete dies als eine Antwort mit Hoffnungen, dass es jemandem in der Zukunft helfen wird, sich mit einem ähnlichen Problem zu befassen.