New Discussion

Notifications

You’re not receiving notifications from this thread.

Getting an simple Ajax request on Rails

1
Rails

Hey guys, just went through the Notifications videos. To see if I understood the concepts correctly, I tried doing my own solo Ajax request on the forum_threads instead of Notifications.

I ran into a roadblock though because I'm only returning an empty [ ] when I do /forum_threads.json I think the issue is in either my controller under index which is as follows.

def index
    @forum_threads = ForumThread.all
    @forum_threads = ForumThread.where(id: :ForumThread_id)
  end

Or in my super simple json.jbuilder which I did by as such:

json.array! @forum_threads do |forum_thread|
    json.url forum_thread_path(forum_thread)
end

If you can help me out would be super helpful. Thank you so much guys :)

Github to the Code: https://github.com/OmarZV/NotificationAjax

Solved the issue - The problem was 4 fold: Turbolinks, my controller file for forum_threads, index.json.jbuilder, and my coffescript file. Hope it helps someone else learning. I have provided the answer in SO in case anyone else is stuck in a similar issue.
http://stackoverflow.com/questions/41024125/simple-ajax-request-with-rails-bootstrap

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 88,834+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.