Skip to content

Instantly share code, notes, and snippets.

@paneq
Created December 16, 2011 11:14
Show Gist options
  • Save paneq/1485683 to your computer and use it in GitHub Desktop.
Save paneq/1485683 to your computer and use it in GitHub Desktop.
Proposed solution for controller / view communication.
class PapersController < ApplicationController
def create
@paper = Paper.new(params[:paper])
if @paper.save
redirect_to @paper, notice: :created
else
flash[:alert] = :invalid
render action: :new
end
end
end
<% if notice == :created %>
<div class="alert-message block-message success fade in" data-alert="alert">
<a class="close" href="#">×</a>
<p>
<strong>Well done!</strong> You successfully proposed a paper for wroc_love.rb conference.</p>
<div>Please <strong>bookmark this page</strong> if you want to modify your proposal later</div>
<div class="alert-actions">
<%= link_to "Tweet about it!", "http://twitter.com/", :class => "btn small" %>
<%= link_to "or not", request.path, :class => "btn small" %>
</div>
</div>
<% end %>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment