如何使用smtpapi-ruby gem将我的rails邮件绑定到Sendgrid?我已经按照他们有限的文档,但我的电子邮件没有通过,我已经验证我的SendGrid实现只是发送一个普通的电子邮件,所以不是这样.这就是我所拥有的:
user_controller.rb
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
header = Smtpapi::Header.new
header.add_to(@user.email)
header.add_substitution('user', [@user.name])
header.add_substitution('body', "You've registered! This is from the controller.")
header.add_filter('templates', 'enable', 1)
header.add_filter('templates', 'template_id', 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx')
header.to_json
UserNotifier.welcome(header).deliver
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
Run Code Online (Sandbox Code Playgroud)
邮寄/ user_notifier.rb
class UserNotifier < ApplicationMailer
default …Run Code Online (Sandbox Code Playgroud) 我在我的系统上安装了rbenv,并且我正在尝试bundle install在我的ruby应用程序中运行标准命令.我收到以下错误:
activesupport-5.0.1 requires ruby version >= 2.2.2, which is incompatible with the current version, ruby 1.9.3p484
我已经检查了我的一切,并且不确定1.9.3...自从我2.3.0安装以来它在哪里获得了旧版本的ruby :
> rbenv versions
system
* 2.3.0 (set by /neo-main/.ruby-version)
> ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [i686-linux]
> echo $PATH
/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Run Code Online (Sandbox Code Playgroud)
我重新启动只是为了确保没有东西卡在内存或其他任何东西.
我尝试在没有 SSL 的情况下连接到本地主机 postgresql 服务器,但收到此错误:
pq: SSL is not enabled on the server
Run Code Online (Sandbox Code Playgroud)
没关系,我知道如何解决它:
type App struct {
Router *mux.Router
DB *sql.DB
}
func (a *App) Initialize(dbname string) {
connectionString := fmt.Sprintf("dbname=%s sslmode=disable", dbname)
var err error
a.DB, err = sql.Open("postgres", connectionString)
if err != nil {
log.Fatal(err)
}
defer a.DB.Close()
}
Run Code Online (Sandbox Code Playgroud)
但是我仍然收到错误!
我有一个带有一系列选项菜单的bash脚本,该脚本允许用户设置其新系统,这是Ubuntu服务器,没有GUI,只有CLI(它将是虚拟机映像)。
我已经通过编辑/etc/default/grub和来强制进行root登录/etc/init/tty1.conf,因此用户直接放入了root命令提示符。从那里,用户必须输入./whiptail.sh以启动脚本并获得提示信息以进一步设置主机。
现在,我希望我的脚本是登录后显示的内容,而不是将用户拖放到命令提示符下的内容。我怎样才能做到这一点?
Owl Carousel无法与我的滑轨安装配合使用。它没有显示在我的测试页上,并且此错误显示在Chrome开发者控制台中:

未捕获的TypeError:undefined不是函数
我已经按照https://github.com/acrogenesis/owlcarousel-rails上的指示进行操作
并且即使由于滑轨显然turbolinks混乱与DOM触发安装此修复程序。
这是Rails中的相关代码:
**GemFile**
gem 'owlcarousel-rails'
**app/assets/application.js**
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require owl.carousel
//= require_tree .
**app/assets/stylesheets/application.css**
*= require_tree .
*= require_self
*= require owl.carousel
*= require owl.theme
**home.html.erb**
<body>
...
<div class="owl-carousel" col-lg-12">
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content </div>
<div> Your Content …Run Code Online (Sandbox Code Playgroud) 我从Virtualbox导出了一个完全完成的虚拟机映像,并尝试使用我创建的脚本进行无人值守的设置.所以,当我到达apt-get upgrade这个窗口时,最终弹出,这使我的脚本挂起.用户根本不必与设置进行交互.
如何自动为用户通过此操作?或者只是忽略grub更新?
谢谢!
我正在设置我的 Docker 环境并尝试让 sidekiq 与我的其他服务一起启动docker-compose up,但是 sidekiq 在尝试连接到错误的redis URL 时抛出错误:
redis_1 | 1:M 19 Jun 02:04:35.137 * The server is now ready to accept connections on port 6379
sidekiq_1 | Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
Run Code Online (Sandbox Code Playgroud)
我非常有信心在我的 Rails 应用程序中没有引用会让 Sidekiq 连接到 localhost 而不是redis在 docker-compose.yml 中创建的服务:
version: '3'
services:
db:
image: postgres
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/app
ports:
- 3000:3000
depends_on:
- db
redis: …Run Code Online (Sandbox Code Playgroud) 将另一个分区添加到已分区表的最佳方法是什么?
原始CREATE TABLE语句如下所示:
CREATE TABLE `command_log` (
`id` bigint(20) NOT NULL,
`insert_time` datetime NOT NULL,
`start_time` timestamp NULL DEFAULT '0000-00-00 00:00:00',
`end_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`command` varchar(255) NOT NULL,
`parameters` varchar(255) DEFAULT NULL,
`result` mediumblob,
`status` int(11) NOT NULL,
PRIMARY KEY (`id`,`insert_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE (to_days(insert_time))
(PARTITION p001 VALUES LESS THAN (736237) ENGINE = InnoDB,
PARTITION p002 VALUES LESS THAN (736268) ENGINE = InnoDB,
PARTITION p003 VALUES LESS THAN (736298) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将富文本编辑器合并到我的应用程序中,但运气不佳。我本来打算使用 CKEditor,但发现 Rails 6 的 actiontext/trix 集成得很好……或者我是这么想的。
我遵循了https://edgeguides.rubyonrails.org/action_text_overview.html 中的标准安装步骤
所以,除非我错过了什么,我现在在这些文件中有以下代码:
应用程序/javascript/packs/actiontext.scss
@import "trix/dist/trix";
.trix-content {
.attachment-gallery {
> action-text-attachment,
> .attachment {
flex: 1 0 33%;
padding: 0 0.5em;
max-width: 33%;
}
&.attachment-gallery--2,
&.attachment-gallery--4 {
> action-text-attachment,
> .attachment {
flex-basis: 50%;
max-width: 50%;
}
}
}
action-text-attachment {
.attachment {
padding: 0 !important;
max-width: 100% !important;
}
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序/javascript/packs/application.js
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
import $ from 'jquery';
import 'bootstrap/dist/js/bootstrap';
$(document).on('turbolinks:load', function() {
$('body').tooltip({
selector: '[data-toggle="tooltip"]',
container: …Run Code Online (Sandbox Code Playgroud) 我在我的 Rails 应用程序中嵌套了资源,基本上是一个Projecthas Targets,我认为创建关系的最简单方法是在我的 routes.rb 中执行此操作:
resource :projects do
resource :targets
end
Run Code Online (Sandbox Code Playgroud)
我的模型也非常匹配:
- Project.rb
class Project < ApplicationRecord
has_many :targets
end
- Target.rb
class Target < ApplicationRecord
has_one :project
end
Run Code Online (Sandbox Code Playgroud)
跑步rake routes向我展示了我的期望:
project_targets GET /projects/:project_id/targets(.:format) targets#index
POST /projects/:project_id/targets(.:format) targets#create
new_project_target GET /projects/:project_id/targets/new(.:format) targets#new
edit_project_target GET /projects/:project_id/targets/:id/edit(.:format) targets#edit
project_target GET /projects/:project_id/targets/:id(.:format) targets#show
PATCH /projects/:project_id/targets/:id(.:format) targets#update
PUT /projects/:project_id/targets/:id(.:format) targets#update
DELETE /projects/:project_id/targets/:id(.:format) targets#destroy
projects GET /projects(.:format) projects#index
POST /projects(.:format) projects#create
new_project GET /projects/new(.:format) projects#new
edit_project GET /projects/:id/edit(.:format) …Run Code Online (Sandbox Code Playgroud) linux ×3
ruby ×3
bash ×2
ubuntu ×2
actionmailer ×1
actiontext ×1
docker ×1
go ×1
javascript ×1
jquery ×1
mysql ×1
owl-carousel ×1
postgresql ×1
sendgrid ×1
sidekiq ×1
ssl ×1
trix ×1
ubuntu-14.04 ×1