This file contains hidden or 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
| require 'yandex-translator' | |
| class Translate | |
| attr_accessor :words_for_translate | |
| attr_reader :translated_word | |
| def initialize(words) | |
| set_api_key | |
| @words_for_translate = words | |
| end | |
| def translate(options = nil) |
This file contains hidden or 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
| # encoding: utf-8 | |
| class User < ActiveRecord::Base | |
| attr_accessor :read # user's agreement | |
| scope :unbanned, where(:banned => false) | |
| scope :last_users, ->(count) { order("id DESC").limit(count) } | |
| include Models::User::City | |
| include Models::User::MessageStuff |
This file contains hidden or 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
| require "rvm/capistrano" # Load RVM's capistrano plugin. | |
| require "bundler/capistrano" | |
| set :rvm_ruby_string, '1.9.3' | |
| set :rvm_type, :user # Literal ":user" | |
| set :application, "blog_test" | |
| set :repository, "[email protected]:ryancheung/blog.git" | |
| set :scm, :git |
This file contains hidden or 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
| def create | |
| @recipient = User.find(params[:message][:recipient_id]) | |
| @message = current_user.send_message(@recipient, params[:message][:body]) | |
| images_params = params[:message][:images_attributes] | |
| respond_with(@message) do |format| | |
| if @message.save! | |
| if images_params.present? | |
| uploader = AmazonImageUploader.new(@message.id, images_params) | |
| uploader.process | |
| end |
This file contains hidden or 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
| #In class | |
| class AmazonImageUploader | |
| def initialize(id, file) | |
| name = file[0][:image].original_filename | |
| directory = "public/uploads/" | |
| path = File.join(directory, name) | |
| File.open(path, "wb") { |f| f.write(file[0][:image].read) } | |
| @path = path | |
| @id = id | |
| end |
This file contains hidden or 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 MessageImageWorker | |
| @queue = :message_image_queue | |
| def self.perform(message_id, image) | |
| message = Message.find(message_id) | |
| message.images << MessageImage.create!(image: image) | |
| end | |
| end |
This file contains hidden or 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 AmazonImageUploader | |
| def initialize(id, file) | |
| name = file[0][:image].original_filename | |
| directory = "public/uploads/" | |
| path = File.join(directory, name) | |
| File.open(path, "wb") { |f| f.write(file[0][:image].read) } | |
| @file = path | |
| @id = id | |
| end |
This file contains hidden or 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
| MacBook-Pro-egor.local:17096 on MESSAGES_QUEUE at just now Retry or Remove | |
| Class | |
| AddImageToMessage | |
| Arguments | |
| 131 | |
| [{"image"=>{"original_filename"=>"kfc.png", "content_type"=>"image/png", "headers"=>"Content-Disposition: form-data; name=\"message[images_attributes][][image]\"; filename=\"kfc.png\"\r\nContent-Type: image/png\r\n", "tempfile"=>["�PNG\r\n", "\u001A\n", "\u0000\u0000\u0000\rIHDR\u0000\u0000\u0000�\u0000\u0000\u0000�\b\u0006\u0000\u0000\u0000�X��\u0000\u0000\u0000\u0006bKGD\u0000�\u0000�\u0000�����\u0000\u0000\u0000\atIME\a�\u0004\u0019\u000F\u0016!7\u0011\u001A-\u0000\u0000 \u0000IDATx���wt\u0014�����m��$��{�]D@\u0001�M�t\u0011\u0005EA�l(XP\u0004\u0015\u0010Q�H���S� �t�\"��P\u0013\b\u0010 !��-3�\u001FK����4\u0012���\u001C�w��\\6������\u001F��\u001Fv\u0011\n", "{\u0000�\u0018\u0001@\t \b�X\u001DK\u0000\u0012��\a?��\u001D�\u007F\u0014\u0004�\t�2��\u0016@#�\u0001P\u001D(\u000F�\\<�\u0000D\u0000\u0017�0�\fp\u0002�\u00170��P�� �O@�h\b�\u0000t�,\u0014b\u0001�#\u00118T]T��Qi���b�\n", "Q� {��\u0013�=$Av\u |
This file contains hidden or 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 Post < ActiveRecord::Base | |
| resourcify | |
| belongs_to :user | |
| belongs_to :journal, :polymorphic => true | |
| has_many :images, :class_name => "PostImage", :as => :imageable, :dependent => :destroy | |
| has_one :illustration, :class_name => "PostIllustration", :as => :imageable, :dependent => :destroy | |
| accepts_nested_attributes_for :illustration | |
| accepts_nested_attributes_for :images,\ |
This file contains hidden or 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
| <body> | |
| <div id="sv-header"> | |
| <div class="sv-wrapper clearfix"> | |
| <div id="sv-search-box"> | |
| <%= render :partial=> 'layouts/sv-search-box' %> | |
| </div> | |
| <div id="sv-sign-box"> | |
| <% if user_signed_in? %> | |
| <div class="sv-logged-box clearfix"> | |
| <div class="avatar"><div class="border"><a href="<%= user_path(current_user) %>"><%= image_tag current_user.avatar %></a></div></div> |