Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:42:37+00:00 2026-06-08T21:42:37+00:00

I have two issues and can’t figure out why! I have followed the tutorial

  • 0

I have two issues and can’t figure out why! I have followed the tutorial of http://ruby.railstutorial.org/chapters/

Problem #1: My login and logout don't seem to be working
Problem #2: My private function doesn't see sign_in? -- I believe however is because sign_in? is declared in the sessionHelpers and I declared this function in the customerController which would explain why I can't see but don't know how to make it see.

Here the code I have!
model/customer.rb
controller/sessions

class SessionsController < ApplicationController
    def new
    end

    def create
        customer = Customer.find_by_email(params[:session][:email])
        if customer && customer.authenticate(params[:session][:password])
                # Sign the user in and redirect to the user's show page.
            sign_in customer
            redirect_back_or customer
        else
            flash.now[:error] = 'Invalid email/password combination'
            render 'new'
        end

    end

    def destroy
        sign_out
        redirect_to root_path
    end
end

controller/customers

class CustomersController < ApplicationController
    before_filter :signed_in_customer, only: [:edit, :update]
    before_filter :correct_customer,   only: [:edit, :update]

    def new
        @customer = Customer.new
    end

    def create
        @customer = Customer.new(params[:customer])
        if @customer.save
            sign_in @customer
            flash[:success] = "Welcome to Where you Where"
            redirect_to @customer
        else
            render 'new'
        end
    end

    def show
        @customer = Customer.find(params[:id])
    end

    def edit
        @customer = Customer.find(params[:id])
    end

    def update
        @customer = Customer.find(params[:id])
        if @customer.update_attributes(params[:customer])
            flash[:success] = "Profile updated"
            sign_in @customer
            redirect_to @customer
        else
            render 'edit'
        end
    end

    def index
        @customers = Customer.all
    end

    private
        def signed_in_customer
            unless signed_in?
                store_location
                redirect_to signin_path, notice: "Please sign in."
            end
        end

            def correct_customer
                @customer = Customer.find(params[:id])
                redirect_to(root_path) unless current_customer?(@customer)
            end
end

helpers/sessions

module SessionsHelper
    def sign_in(customer)
        cookies.permanent[:remember_token] = customer.remember_token
        self.current_customer = customer
    end

    def sign_in?
        !current_customer.nil?
    end

    def current_customer=(customer)
        @current_customer = customer
    end

    def current_customer?(customer)
        customer = current_customer
    end

    def current_customer
        @current_customer ||= Customer.find_by_remember_token(cookies[:remember_token])
    end

    def sign_out
        self.current_customer = nil
        cookies.delete(:remember_me)
    end

    def redirect_back_or(default)
            redirect_to(session[:return_to] || default)
            session.delete(:return_to)
    end

    def store_location
            session[:return_to] = request.fullpath
    end
end

Thanks again, sorry for the misspell

Update:

Application Controller

class ApplicationController < ActionController::Base
    protect_from_forgery
    before_filter :pages

    def pages
        @pages = Page.all
    end
    include SessionsHelper
end

Here the error when trying to edit the customer

undefined method `signed_in?' for #<CustomersController:0xb56089ec>
app/controllers/customers_controller.rb:45:in `signed_in_customer'

NOTE:: I just did db:reset and created a new account. I was successfull but the link in the header are shown has i am logout.

Here the header file

<header class="header">
  <div class="menu">
    <div class="center">
    <div class="logo">
          <nav>
        <ul>
        <% if sign_in? %>
            <div>Welcome <%= current_customer.full_name %> </div>
            <li><%= link_to "Home", root_path %></li>
            <li><%= link_to "Customers", customers_path %></li>
                <li><%= link_to "Profile", current_customer %></li>
                <li><%= link_to "Settings", edit_customer_path(current_customer) %></li>
                <li><%= link_to "Sign out", signout_path, method: "delete" %></li>
        <% else %>
            <li><%= link_to "Home", '#' %></li>
                <li><%= link_to "Sign in", '#' %></li>
        <% end %>
        </ul>
          </nav>
    </div>
    </div>
  </div>
</header>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:42:40+00:00Added an answer on June 8, 2026 at 9:42 pm

    Make sure you include the helper in ApplicationController

    class ApplicationController < ActionController::Base
      protect_from_forgery
      include SessionsHelper
    end
    

    This means any controllers that inherit from ApplicationController (such as CustomersController) in your example will be able to access the methods in your helper

    I haven’t looked through all your code but let me know if this solves both your problems, if not let me know and I’ll have a longer look

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm new to JQuery. I have an two issues that I can't figure
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
I have two classes: Vehicle and Issues ....a Vehicle object can have several issues
I have two issues:- Issue No :1 (PHP related) I can't display an array
Here's the jfiddle for what I'm trying to achieve: http://jsfiddle.net/fmvmA/ I have two issues
I can add a QPixMapImage to a QGraphicsScene, but then I have two issues.
I am just starting out with shell scripting (sh), and I have two issues.
I have two issues in this google chart. I want to either get rid
I need to override styles for two EditText instances. I have two issues regarding
I have found many people with simliar issues but no soultions...basically I have two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.