Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Getting an simple Ajax request on Rails

Rails • Asked by Omar Khedr

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)

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)

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

Github to the Code:

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.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.