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
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, |
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 User < ApplicationRecord | |
has_many :posts | |
has_many :favorites | |
has_many :favorite_posts, through: :favorites, source: :post | |
end | |
class Post < ApplicationRecord | |
belongs_to :user |
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
>> str = "http://yoursite.com/news/blabla" | |
=> "http://yoursite.com/news/blabla" | |
>> str.match(/(.*yoursite.com\/news\/?).*/) [1] | |
=> "http://yoursite.com/news/" |
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
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 |
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
# 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 |