- First-use of the message template
<% renders messages/_message.html.erb %>
<%= render @messages %>
- Form submitting via Ajax
<%= form_for @project.messages.new, remote: true do |form| %>
...
<%= form.submit "Send message" %>
<% end %>
- Server creates the model object
class MessagesController < ActionController::Base
def create
@post = @project.messages.create!(message_params)
respond_to do |format|
format.html { redirect_to @message } # no js fallback
format.js # just renders messages/show.js.erb
end
end
end
- Server generates a JavaScript view
<%# renders messages/_message.html.erb %>
$('#messages').prepend('<%=j render @message %>');
$('#<%= dom_id @message %>').highlight();
- Automatic evaluation of response