Getting an simple Ajax request on 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.