title: Problems keeping an object in an array, Ruby issues and Rails issues
body: <p>I'm trying to add an object to my array, however the array seems to always reset, instead of adding. What am I doing wrong? I think it has to do with <code>if(defined? libraryshelf) then</code>, What I'm trying to do here is find out of the array exists or not (if this is the first add or not)..</p>
  
  <pre><code>def add_book
    @listofbooks ||= Array.new
    @listofbooks.push(params[:booktitle])
    @listofbooks
    respond_to do |format|
      format.html { redirect_to(:back) }
      format.js
    end
  end
  </code></pre>
  
  <p>my add_book.js.erb file</p>
  
  <pre><code>alert('&lt;%= @listofbooks %&gt;');
  </code></pre>
  
  <p><code>@listofbooks</code> only shows the title of the book I last added.. </p>