title: Rails + CarrierWave: NoMethodError: undefined method `image_url' for nil:NilClass
body: <p>I'm using Devise and Carrierwave. I genderated users with devise then created a separate user controller where this page is now (users/search)</p>
  
  <p>Carrierwave was working perfectly and displaying images in my show (users/1 etc) however when I have moved things over to the new 'search' page, its broken.</p>
  
  <p>Here's the code in my view.. (note, the view works when I remove the image, so the other code is fine)</p>
  
  <pre><code>&lt;% @males.each do |user| %&gt;
    &lt;%= image_tag @user.image_url(:thumb).to_s %&gt;
    &lt;%= user.firstname %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I've tried adding in my users_controller: </p>
  
  <pre><code>def search
    @users = User.all
  end
  </code></pre>
  
  <p>As you might be able to tell by the code in my view I am filtering users by gender (which ive defined @males and @females) You can see that in my model below.</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable
  
    attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :firstname, :lastname, :gender, :image, :remote_image_url, :image_cache, :remove_image
  
    mount_uploader :image, ImageUploader
  
    scope :male, -&gt; { where gender: 'male' }
    scope :female, -&gt; { where gender: 'female' }
  </code></pre>
  
  <p>I've tried adding :image_url to both attr_accessible and mount_uploader and it didn't work, however I know that would not be the problem as I said it works fine in the show. </p>
  
  <p>Any ideas ??</p>
  
  <p>note: I've checked all related questions on here and I still can't find a solution which helps me. Thanks very much</p>