class PhotosController
def render_image
photo = Photo.find(params[:photo_id)
send_data photo.photo, type: 'image/png', disposition: 'inline'
end
end
# config/routes.rb
get '/photos/:photo_id' => 'photos#render_image'
ssh root@server.ru -R6666:localhost:3000
server {
listen 443 ssl;
server_name server.ru;
location / {
proxy_pass http://localhost:6666;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_host;
}
}
# https://stackoverflow.com/a/15198031
% ssh -M -S expose.socket -fnNT -R 6666:localhost:3000 root@server.ru
% ssh -S expose.socket -O check root@server.ru
Master running (pid=71660)
% ssh -S expose.socket -O exit root@server.ru
print 'Введите что-нибудь: '
t = STDIN.gets
puts "Вы ввели: #{t}"
def move=(distantion)
if value == ""
raise "Введите куда движется"
end
@distantion = value
end
require 'net/http'
xml_file_content = File.read("xml_file.xml")
uri = URI('https://integration.cdek.ru/new_orders.php')
res = Net::HTTP.post_form(uri, 'xml_request': xml_file_content)
puts res.body
ActiveRecord::Base.transaction do
checker_result.save
end
class CheckerError < ApplicationRecord
belongs_to :checker_result
def delete_if_some
raise ActiveRecord::Rollback
end
end
c:\Ruby\Ruby2.3.0\bin>rake generate_secret_token
cd C:\webserver\Redmine
class News < ActiveRecord::Base
belongs_to :user, foreign_key: :login, primary_key: :login
end
class User < ActiveRecord::Base
has_many :news, foreign_key: :login, primary_key: :login
end
class CreateNews < ActiveRecord::Migration
def up
create_table :news do |t|
t.string :login, limit: 50
t.timestamps null: false
end
add_foreign_key :news, :users, column: :login
end
def down
remove_foreign_key :news, name: :login
drop_table :news
end
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users, id: false, primary_key: :login do |t|
t.string :login, limit: 50, null: false
t.timestamps null: false
end
end
end
...
redirect_to @post, :success => "Post was successfully updated"
...
It is also possible to assign a flash message as part of the redirection. There are two special accessors for the commonly used flash names alert and notice as well as a general purpose flash bucket
If you're using Windows Subsystem for Linux then there are currently some limitations on file system notifications that mean you should disable the spring and listen gems which you can do by running rails new blog --skip-spring --skip-listen.
subscriber = Subscriber.new
subscription = sub.subscriptions.build
subscription.periods.build
subscriber.save