如何保存ActionMailbox inbound HTML email和关于ActionText与ActiveStorage的附加
gi代码:
新建一个rails6
需要
gem 'image_processing'
gem 'whenever', require: false
rails action_text:install
(参考https://www.cnblogs.com/chentianwei/p/10515183.html ,
https://www.cnblogs.com/chentianwei/p/10655122.html )
rails webpacker:install:stimulus
yarn add tributejs
#app/javascript/packs/application.js
#...
+require("trix")
+require("@rails/actiontext")
rails g scaffold Post title:string
rails db:migrate后
#app/models/post.rb
# 这里给post记录挂上关联的actiontext和attachment。
class Post < ApplicationRecord
has_rich_text :body
has_many_attached :attachments
end
rails action_mailbox:install
所有入境的邮件都让posts处理。
#app/mailboxes/application_mailbox.rb
class ApplicationMailbox < ActionMailbox::Base
# routing /something/i => :somewhere
routing :all => :posts
end
rails g mailbox Posts
..
app/views/posts/_form.html.erb 修改代码,添加richtext,并根据post是否存在,添加删除和返回按钮。
<div class="field">
<%= form.label :title %>
<%= form.text_field :title, class: 'form-control' %>
</div> <div class="form-group">
<%= form.label :body %>
<%= form.rich_text_area :body, class: 'form-control' %>
</div> <div class="form-group">
<% if post.persisted? %>
<div class="float-right">
<%= link_to "Destroy", post, method: :delete, class:'text-danger', data: {confirm: "Are you sure?"}%>
</div>
<% end %> <%= form.submit class: 'btn btn-primary'%> <% if post.persisted? %>
<%= link_to "Cancel", post, class: "btn btn-link"%>
<% else %>
<%= link_to "Cancel", posts_path, class: "btn btn-link"%>
<% end %>
</div>
<% end %>
app/views/posts/index.html.erb 修改代码:
+ <td><%= post.body %></td>
app/views/posts/show.html.erb 修改代码:
<div class="page-header">
<%= link_to posts_path, class: 'btn btn-default' do %>
All Posts
<% end %>
<%= link_to edit_post_path(@post), class: 'btn btn-primary' do %>
Edit
<% end %>
<h1>Show post</h1>
</div> <dl class="dl-horizontal">
<dt>Title:</dt>
<dd><%= @post.title %></dd> <dt>Body:</dt>
<dd><%= @post.body %></dd> </dl> <% @post.attachments.each do |attachment| %>
<div><%= link_to attachment.filename, attachment %></div>
<% end %>
配置:
如何保存ActionMailbox inbound HTML email和关于ActionText与ActiveStorage的附加的更多相关文章
- salesforce零基础学习(九十三)Email To Case的简单实现
Salesforce提供了标准的功能来实现通过Email 创建 Case.我们可以设置指定的路由的地址,指定条件的邮件会自动生成到目标salesforce系统的Case数据.Salesforce提供了 ...
- 推荐几款我一直在用的chrome插件(下)
请先看:推荐几款我一直在用的chrome插件(上) 6. Pocket 可以很方便的保存文章.视频等供以后查看,即实现了“Read it later”功能.有了 Pocket,您可以将所有想下次读的内 ...
- 如何在ubuntu中启用SSH服务
如何在ubuntu14.04 中启用SSH服务 开篇科普: SSH 为 Secure Shell 的缩写,由 IETF 的网络工作小组(Network Working Group)所制定:SSH 为 ...
- 怎样使用 GitHub?
作者:珊姗是个小太阳链接:https://www.zhihu.com/question/20070065/answer/79557687来源:知乎著作权归作者所有,转载请联系作者获得授权. 作为一个文 ...
- Http客户端识别的方法
Http用户识别的机制方法分为如下几种: 1).承载用户身份的HTTP首部 2).客户端IP地址跟踪,根据客户端IP地址进行识别 3).用户登录,用认证方式设别用户 4).使用胖URL,一种在UR ...
- Orchard创建自定义表单
本文链接:http://www.cnblogs.com/souther/p/4520130.html 主目录 自定义表单模块可以用来获取网站前台用户的信息.自定义表单需要与一个内容类型结合使用.它可以 ...
- ylbtech-dbs-m-QQ邮箱
ylbtech-dbs:ylbtech-dbs-m-QQ邮箱 -- =============================================-- DatabaseName:QQ-Em ...
- 转:怎么使用github(通俗易懂版)
转: https://www.zhihu.com/question/20070065 作者:珊姗是个小太阳链接:https://www.zhihu.com/question/20070065/ans ...
- 版本控制工具--GIT 基本命令(1)
一.安装GIT,在官网上下载安装即可(下面模拟环境是window7) 二.基本操作: 1.创建GIT库: ①先使用mkdir命令创建一个空目录,再使用git init将该目录变成GIT库,会在该目录下 ...
随机推荐
- 安装gnocchi
在控制节点上执行 #!/bin/bash MYSQL_ROOT_PASSWD='m4r!adbOP' GNOCCHI_PASSWD='gnocchi1234!' CEILOMETER_PASSWD=' ...
- Redis集群的原理和搭建(转载)
转载来源:https://www.jianshu.com/p/c869feb5581d Redis集群的原理和搭建 前言 Redis 是我们目前大规模使用的缓存中间件,由于它强大高效而又便捷的功能,得 ...
- mysql 插入数据后返回自增 ID 的七种方法
参考地址:https://blog.csdn.net/qq_30715329/article/details/80868411 其中使用函数方式.存储过程方式.注解方式.xml属性方式设置都可. 常用 ...
- 数据结构 双向链表 C语言实现
dlist.h #ifndef __dList_H #define __dlist_H typedef int Item; typedef struct Node *PNode; typedef PN ...
- Design Phone Directory
Design a Phone Directory which supports the following operations: get: Provide a number which is not ...
- MySQL_bigint(20) 是什么意思?
MySQL_bigint(20) 是什么意思? MySQL的整型类型有这样几种: 类型 存储空间 M默认值(显示宽度) 数据大小(无符号:unsigned) 描述 1 tinyint(M) 1 t ...
- c++11特性
0. 简介 在c++11标准中, 语言本身和标准库都增加了很多新内容. 里面的某些特性, 会让你在代码编写时更优雅. 我的环境: 系统: ubuntu16.04 g++版本: g++5.4.0 使用c ...
- OVS+Docker
两台机器操作一样就是IP不同但是设置都是相同的: A机器:192.168.71.142 docker0:172.17.42.1 B机器:192.168.71.136 docker0:172.17.43 ...
- 并不对劲的复健训练-CF1187D
题目大意 有两个长度为\(n\)的序列\(a_1,...,a_n\),\(b_1,...,b_n\)(\(a,b\leq n\leq 3\times 10^5\) ).一次操作是选取 \([l,r]\ ...
- 并不对劲的复健训练-p3674
题目大意 给出序列$ a_1,...,a_n $ ( $ n\leq10^5,a\leq 10^5 $ ),有\(m\) ( \(m\leq 10^5\))个以下三类询问: (1)给出\(l,r,k\ ...