Created
December 29, 2011 15:21
-
-
Save MichaelEvans/1534538 to your computer and use it in GitHub Desktop.
JS Displayed, Not Executed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".span2").prepend("<%= escape_javascript(render(@blip)) %>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# 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