如何保存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库,会在该目录下 ...
随机推荐
- Exchange2010---反垃圾邮件配置
Exchange2010---反垃圾邮件配置 Exchange2010---反垃圾邮件配置 本文以Exchange Server 2010作为反垃圾邮件配置实例为例. 其实,在微软发布的Exc ...
- 深入理解C语言-结构体做函数参数
结构体做函数参数,在C语言中属于常见现象,此时为了内存考虑,不传递结构体,而是传递结构体的地址 结构体定义 struct Man { char name[64]; int age; }; 结构体可以与 ...
- sql普通语句
select DISTINCT t_id from nrc_newsDISTINCT不会输出相同的值select top 5 * from nrc_news;检索前五行select * from nr ...
- double write 双写
Oracle 8KB Postgresql 8KB MySQL Innodb 16KB buffer page block首先,要DML数据,需要先把page读取到index page中,之后对内存中 ...
- X-UA-Compatibles
今天在看京东网页代码的时候,发现了X-UA-Compatibles 这个元信息属性,不是很清楚,百度了一下,做下记录 X-UA-Compatible 属性是 IE 浏览器在 IE8 版本开始提供的一个 ...
- dmesg、stat命令
一.dmesg:系统启动异场诊断. 语法: dmesg [选项] 参数: -C,-清除 清除环形缓冲区. -c,--read-clear ...
- WebMvcConfigurationSupport跨域和fastjson全局替换
@Configuration public class WarnWebMvcConfigurationSupport extends WebMvcConfigurationSupport { /** ...
- Codeforces 1236E. Alice and the Unfair Game
传送门 首先可以注意到对于固定的起点 $S$ ,它最终能走到的终点一定是一段区间 这个用反证法容易证明,假设合法区间存在断点,这个点左右都可以作为终点 那么分成区间断点在起点左边和起点右边讨论一下即可 ...
- 5.Shell变量
5.Shell变量本章介绍 shell 中所使用的变量.Bash 会自动给其中一些变量赋默认值.5.1 波恩Shell的变量Bash 使用一些和波恩 shell 同样的变量.有时,Bash 会给它赋默 ...
- EasyUI_前台js_省市县三级联动
1.html: <td class="tdl">所属城市</td> <td class="td_detail"> <i ...