-
-
Save Josebuendia/b22486363fdffe470b27b34daad2cc9b to your computer and use it in GitHub Desktop.
user_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserController < ApplicationController | |
def login | |
session[:login] = 1 | |
session[:cart] = nil | |
#Changed the line below to Seller Login sucessfull! from "Admin Login sucessfull!" | |
flash[:notice] = "Seller Login sucessfull!" | |
redirect_to :controller => :items | |
end | |
def logout | |
session[:login] = nil | |
session[:cart] = nil | |
flash[:notice] = "You have been successfully logged out!!" | |
redirect_to :controller => :items | |
end | |
#iteration for farmers page | |
def farmers | |
#@users = User.where(role: 1) | |
@users = User.select(:farm_name, :avatar, :about_farm, :farm_type, :county).where(role: 1) | |
end | |
def search | |
st = "%#{params[:q]}%" | |
@users = User.where("email like ?", st) | |
end | |
def show | |
end | |
#def farmers | |
# @user = User.find(params[:id]) | |
# FIXME get the view working for the farmers page | |
#end | |
def upgrade_admin | |
@user.update_attribute(:adminrole, true) | |
redirect_to :action => :admin_users | |
end | |
def downgrade_admin | |
@user.update_attribute(:adminrole, false) | |
redirect_to :action => :admin_users | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment