Note that there are some explanatory texts on larger screens.

plurals
  1. POWhile trying to loop through all users, all the hidden table data is displayed for each user
    primarykey
    data
    text
    <p>So I am trying to list all the users that have registered on my site, but I am getting all the table data for each user on my view page.</p> <p>User_controller.rb :</p> <pre><code>class UsersController &lt; ApplicationController before_filter :authenticate_user! def index @users = (current_user.blank? ? User.all : User.find(:all, :conditions =&gt; ["id != ?", current_user.id])) end def show if params[:id].nil? &amp;&amp; current_user @user = current_user else @user = User.find(params[:id]) end @cereal = current_user.cereals.build if signed_in? @cereals = @user.cereals.paginate(page: params[:page]) end def first_time if params[:id].nil? &amp;&amp; current_user @user = current_user else @user = User.find(params[:id]) end end def edit if params[:id].nil? &amp;&amp; current_user @user = current_user else @user = User.find(params[:id]) end end def profile @username = params[:id] @friends = current_user.friends || [] @title = "User Profile for #{@username}" @user = User.find_by_username(@username) @users = User.all :conditions =&gt; ["id != ?", current_user.id] end end </code></pre> <p>User.rb(model)</p> <pre><code>class User &lt; ActiveRecord::Base include Amistad::FriendModel mount_uploader :avatar, AvatarUploader has_many :cereals, dependent: :destroy # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys =&gt; [:login] # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :login, :avatar, :avatar_cache, :remove_avatar, :firstname, :lastname, :phone, :urlname # attr_accessible :title, :body attr_accessor :login def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value =&gt; login.downcase }]).first else where(conditions).first end end def update_with_password(params={}) current_password = params.delete(:current_password) if params[:password].blank? params.delete(:password) params.delete(:password_confirmation) if params[:password_confirmation].blank? end result = if params[:password].blank? || valid_password?(current_password) update_attributes(params) else self.attributes = params self.valid? self.errors.add(:current_password, current_password.blank? ? :blank : :invalid) false end clean_up_passwords result end end </code></pre> <p>Views/users/index:</p> <pre><code>= @users.each do |user| %li = user.username </code></pre> <p>Anyone have any idea why when I open the index page for users, everything from the user table in the database is being displayed?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload