How do I implement JS data into my CRUD app with ruby on rails? How do i use AJAX to tabulate showing content?
<p>I am fellow rubyist. I am a junior programmer. I have created an app where a user can post picture along with a caption and add hashtags to it. The name of the model is Muse for code reference.</p>

<p>Everything seems to be working. On the show page I can get the caption to show along with the pictures and the hashtags. What I am looking to do is to tabulate the contents so that when a user clicks on a muse the hashtag button/link the content will show, same goes for the caption. That said I realize that I am going to need ajax to load the content into a div. i am familiar with the process but for some reason i don't feel confident implementing it. Could anyone help me understand what is happening with AJAX, the CRUD and the JQUERY.</p>

<p>rails 4.2 
ruby 2.2.3</p>

<p>Also links are welcomed. :) Suggestions like learning a front-end framework like angular would be greatly appreciated. </p>

<p>here is my code below</p>

<p>MODEL(Muse = Picture + Caption/body + hashtags(not yet implemented))</p>

<pre><code>class Muse &lt; ActiveRecord::Base
  belongs_to :author
  has_attached_file :image, styles: { medium: '184x160&gt;', large:'486x486'}
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

end
</code></pre>

<p>Controller</p>

<pre><code>class MusesController &lt; ApplicationController
  before_action :authenticate_author!
  before_action :find_author, only: [:index, :create]
  before_action :find_muse, only: [:destroy]

  def index
    @author = current_author
    @muses = Muse.all.order('created_at DESC')
  end

  def show
    @author = current_author
    @correct_author = Author.find_by_id(params[:id])
    @author_profile_picture = @correct_author.profile_pictures.last
    @muses = @correct_author.muses.all
  end

  def new
    @author = current_author
    @muse = Muse.new
  end

  def create
    @muse = Muse.new(muse_params)
    @muse.author_id = current_author.id
    if @muse.save
      redirect_to root_path
    else
      render "new"
    end
  end


  def edit
  end

  def update
    if @muse.update(muse_params)
      redirect_to @muse, notice: "You have successfully updated your muse"
    else
      render 'edit'
    end
  end


  def destroy
    @muse.destroy!
      redirect_to root_path
  end

  private

  def find_author
     @author = current_author
  end

  def find_muse
    @muse = Muse.find_by(params[:id])
  end

  def muse_params
    params.require(:muse).permit(:body, :image, :author_id)
  end
end
</code></pre>

<p>View</p>

<pre><code>&lt;div class="col-md-4 muse-home-panel"&gt;
  &lt;div class= 'muses-scroll-container' &gt;
    &lt;% if !@author.muses.any? %&gt;
  &lt;div class="muse-empty-style"&gt;
    &lt;h5&gt;Muses&lt;/h5&gt;
     &lt;p&gt; Just make sure it's all here&lt;/p&gt;
    &lt;div class="thumbnail muse-empty-thumbnail"&gt;
    &lt;%= link_to 'Add Your Muses', new_muse_path, class:'create-new-link-style-2' %&gt;
    &lt;%= link_to '', new_muse_path, class:'glyphicon glyphicon-plus add-muse-icon' %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;% else %&gt;
  &lt;% @author.muses.each do |muse| %&gt;
  &lt;div class ='muse-container'&gt;
      &lt;%= image_tag muse.image.url(:large), class:'muse-style' %&gt;
      &lt;div class="muses-hashtag"&gt;
        &lt;span&gt;hashtags&lt;/span&gt;
      &lt;/div&gt;
      &lt;!--
      &lt;div class="muse-caption-container"&gt;
        &lt;div&gt;caption:&lt;%= muse.body %&gt;&lt;/div&gt;
      &lt;/div&gt; --&gt;
  &lt;/div&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
&lt;/div&gt;
&lt;/div&gt;
</code></pre>