Skip to content

Instantly share code, notes, and snippets.

@Josebuendia

Josebuendia/farmers.html.erb Secret

Created Aug 6, 2020
Embed
What would you like to do?
user_controller.rb
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
You can’t perform that action at this time.