rails 4 -- working with js format from ajax
        Posted  
        
            by 
                user101289
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user101289
        
        
        
        Published on 2014-06-11T04:27:06Z
        Indexed on 
            2014/06/11
            15:25 UTC
        
        
        Read the original article
        Hit count: 296
        
I'm still working on learning Rails, and I have a page with team information that will get updated based on a team's icon click, which fires an ajax call to the controller to populate some tabs.
I've read some good info about how to use format.js in the controller to render a partial from a js.coffee or js.erb file. 
The problem I'm running into is in the coffeescript I think. Right now, I'm getting some data called @schedules from the controller, and passing it to a schedule.js.coffee file that should populate a partial for each record returned and attach it to a table.
// schedule.js.coffee
$.each @schedules, (schedule) ->
    ($ '#schedule_data').append("<%= j render(partial: 'schedules/schedule', locals: { s: schedule }) %>")
This throws an error
`> undefined local variable or method `schedule' for #<#<Class:0x007fe535cd2900>:0x007fe535d32a30>`
I tried simplifying the coffeescript to just log the output:
$.each @schedules, (schedule) ->
    console.log(schedule)
but this prints nothing.
Am I missing something? I am very inexperienced with coffeescript, but it seems like I should be getting some data-- I verified that the schedule items do exist for this team item.
© Stack Overflow or respective owner