We had a use a case in one of our applications we thought it would be
cool if juggernaut (http://juggernaut.rubyforge.org/) updated the
table.  I brought this up in the past and it was shot down for valid
reasons, ie how to deal with concurrency mess that will result.
However in our use case this isn't much of an issue.  Example, we have
a table with a list of devices, in this case iPhones.  We want to pair
our device with our application which requires the iPhone to talk to
our server, once it is paired it is added to our device table.  We
wanted this device table to update in real time as iPhones pair.
Anyways, here is some rough code, it could use clean up but it should
get people started that might want to accomplish something similar.

if device.new_record?
        device.update_attributes(params[:device])
        device.save!

        row_string = render_component_as_string :controller=>
'devices', :action => 'row', :id => device.id
        render :juggernaut => {:type => :send_to_channels, :channels =>
["#{account.id}:devices"]} do |page|
                # Add device to our AS table
                active_scaffold_tbody_id = "devices-tbody"
                empty_message_id = "devices-empty-message"
                active_scaffold_id = "devices-active-scaffold"

                page.insert_html :top, active_scaffold_tbody_id, row_string
                page << 
"ActiveScaffold.stripe($('#{active_scaffold_tbody_id}'))"
                page <<
"ActiveScaffold.hide_empty_message('#{active_scaffold_tbody_id}','#{empty_message_id}');"
                page <<
"ActiveScaffold.increment_record_count('#{active_scaffold_id}');"
        end
        # Send a created code back to the iPhone
        render(:layout => false, :text => "201 Created", :status => "201
Created")
else

Have fun!
Tys
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to