1 Replies - 921 Views - Last Post: 22 March 2018 - 01:07 PM Rate Topic: -----

#1 elsayegh88   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-March 18

Routing issue need help please

Posted 22 March 2018 - 07:38 AM

hello everyone , any help please why my code giving me the error
undefined local variable or method `page' for #<SessionsController:0xf5d2a60>
i am trying to log in

module SessionsHelper

	def sign_in(user)
 remember_token = User.new_remember_token
 cookies.permanent[:remember_token] = remember_token

 user.update_attribute(:remember_token,
User.digest(remember_token))
 self.current_user = user
 session[:user_id] = user.id
 end
 def signed_in?
 !current_user.nil?
 end
 def current_user=(user)
 @current_user = user
 end
 def current_user
 @current_user ||= User.find_by(id: session[:user_id])
 end
 # logs out the current user.
 def signout
 session.delete(:user_id)
 @current_user = nil
end
end






class SessionsController < ApplicationController

	def new
	end 

	def create
	end 

	def destroy
		signout
 respond_to do |format|
 format.html { redirect_to"http://0.0.0.0:3000/" , notice: 'You have
successfully signout!.'}
 end
	end

	def create
 user = User.find_by(email:
params[:session][:email].downcase)
 if user &&
user.authenticate(params[:session][:password])
 # Sign the user in and redirect to the user's show
page.
 sign_in(user)
 current_user
 respond_to do |format|
 format.html {redirect_to "http://0.0.0.0:3000/users/#{user.id}" , notice:'You have successfully signin!.'}
 end
 else
 flash[:notice] ='Invalid login/password
combination'
 render 'new'
 end
end
end




Is This A Good Question/Topic? 0
  • +

Replies To: Routing issue need help please

#2 NeoTifa   User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4550
  • View blog
  • Posts: 19,192
  • Joined: 24-September 08

Re: Routing issue need help please

Posted 22 March 2018 - 01:07 PM

You have def create in there twice, for starters.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1