Created
February 6, 2013 09:32
-
-
Save shlomizadok/4721408 to your computer and use it in GitHub Desktop.
Demonstrates how one can set own cypher for encrypting file with carrierwave_securefile
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
<%= form_for @book, :html => {:multipart => true} do |f| %> | |
<% if @book.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@book.errors.count, "error") %> prohibited this book from being saved:</h2> | |
<ul> | |
<% @book.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<div class="field"> | |
<%= f.label :cypher, t(:encrypt_your_file_with_the_following_cypher) %><br /> | |
<%= f.text_field :cypher %> | |
</div> | |
<div class="field"> | |
<%= f.label :file %><br /> | |
<%= f.file_field :file %> | |
</div> | |
<div class="actions"> | |
<%= f.submit %> | |
</div> | |
<% 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
class Book < ActiveRecord::Base | |
attr_accessible :expiration, :cypher, :file, :user_id, :asset_id | |
mount_uploader :file, BookUploader | |
validates :file, :presence => true | |
def url | |
file | |
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
class BooksController < ApplicationController | |
. | |
. | |
. | |
# GET /books/new | |
# GET /books/new.json | |
def new | |
@book = Book.new | |
respond_to do |format| | |
format.html # new.html.erb | |
format.json { render json: @book } | |
end | |
end | |
. | |
. | |
. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment