Skip to content

Instantly share code, notes, and snippets.

View graffzon's full-sized avatar
🇺🇦
#WeStandWithUkraine

Kirill Zonov graffzon

🇺🇦
#WeStandWithUkraine
View GitHub Profile
@graffzon
graffzon / for-evgeniy.rb
Created September 1, 2019 09:37
for-evgeniy
require 'rails_helper'
RSpec.describe 'POST /api/v1/posts', type: :request do
let(:user) { User.create!(email: 'foo@bar.com', password: '123123')}
let(:model_post) { Post.new(title: 'foobar', text: '123123', user_id: user.id) }
let(:post_params) do
{
post: {
title: model_post.title,
text: model_post.text,
class User < ApplicationRecord
has_many :posts
has_many :favorites
has_many :favorite_posts, through: :favorites, source: :post
end
class Post < ApplicationRecord
belongs_to :user
>> str = "http://yoursite.com/news/blabla"
=> "http://yoursite.com/news/blabla"
>> str.match(/(.*yoursite.com\/news\/?).*/) [1]
=> "http://yoursite.com/news/"
Started POST "/admin/events" for 176.52.48.57 at 2012-02-22 10:50:06 +0000
Processing by Admin::EventsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"lcKRkfFSPQ7n635eF4q9TOHhxZiZ0q+B0aNrPc8GWuQ=", "event"=>{"name"=>"Huhuho", "title"=>"", "url"=>"", "h1"=>"", "category_id"=>"2", "short_description"=>"", "full_description"=>"", "image_big"=>#<ActionDispatch::Http::UploadedFile:0x000000039a2470 @original_filename="x_1b8b4d43.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"event[image_big]\"; filename=\"x_1b8b4d43.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20120222-25725-1xtj5wy>>, "status"=>"suspend", "top1"=>"0", "top2"=>"0", "top3"=>"0", "notes"=>""}, "commit"=>"Сохранить"}
Completed 500 Internal Server Error in 51ms
Errno::ENOENT (No such file or directory - identify -ping /tmp/mini_magick20120222-25725-25pglt.jpg):
subexec (0.2.1) lib/subexec.rb:71:in `spawn'
subexec (0.2.1) lib/subexec.rb:71:in `spawn'
sub
@graffzon
graffzon / worst_migration.rb
Created January 10, 2012 07:08
НИКОГДА!!!! Никогда!!! Никогда не пишите такие миграции. Этож пиздец, товарищи =)
# Never write so terrible migrations!!
# coding: utf-8
class CreateChannelInformations < ActiveRecord::Migration
def self.up
# Часовые пояса
create_table :time_zones do |t|
t.float :offset, :null => false
t.string :title, :null => false