Skip to content

Instantly share code, notes, and snippets.

@MichaelEvans
Created December 29, 2011 15:21
Show Gist options
  • Save MichaelEvans/1534538 to your computer and use it in GitHub Desktop.
Save MichaelEvans/1534538 to your computer and use it in GitHub Desktop.
JS Displayed, Not Executed
class BlipsController < ApplicationController
before_filter :login_required
respond_to :js
def create
@blip = current_user.blips.build(params[:blip])
@blip.created_at = Time.now
#respond_to do |format|
if @blip.save
respond_with(@blip)
else
flash[:notice] = "Message failed to save."
format.html { redirect_to root_path }
end
end
def destroy
end
end
$(".span2").prepend("<%= escape_javascript(render(@blip)) %>")
<%# title "Welcome #{current_user.username}"%>
<div class="well">
<div class="row">
<div class="span10">
<h1>
<%= "Welcome #{current_user.username}!"%>
</h1>
<%= form_for :blip, :url => blips_path(:format => :js), :remote => true do |b| %>
<div class="clearfix">
<%= b.text_area :message, :class => "xxlarge", :rows => 3 %>
</div>
<div class="clearfix">
<% if current_user.blips.count > 0 %>
<%= h "Latest message: #{current_user.blips.last.message}" %>
<% end %>
</div>
<div class="clearfix">
<%= b.submit "Post", :class => "btn primary" %>
</div>
<% end %>
</div>
<div class="span2">
<%= render :partial => "sidebar" %>
</div>
</div>
<%= render :partial => "blips_list", :locals => { :blips => @blips } %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment