如何保存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库,会在该目录下 ...
随机推荐
- ipmitool管理工具
一.ipmitool简介 IPMI(Intelligent Platform Management Interface)智能平台管理接口 1.IPMI的核心是一个专用芯片/控制器(叫做服务器处理器或基 ...
- 【计算机视觉】背景建模之PBAS
本文是根据M. Hofmann等人在2012年的IEEE Workshop on Change Detection上发表的"Background Segmentation with Feed ...
- JS 获取当前定位
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 使用nfsstat命令查看NFS服务器状态
转载于:http://www.cnblogs.com/jankie/archive/2011/09/03/2165851.html nfsstat命令显示关于NFS和到内核的远程过程调用(RPC)接口 ...
- python -- TypeError: 'module' object is not callable
文件: 代码: import pprintmessge = 'It was a bringht cold day in April,and the clocks were striking thrir ...
- 怎么将本地项目放到码云(gitee)上面?图文详解
git的好处什么的,在此就不多赘述.现在很多公司都在用git了. 那么怎么将本地已经有的项目放到码云(gitee)上呢? 前置条件说明: 1:原来项目所在位置:D:\workspace01\class ...
- Ugly Numbers UVA - 136(优先队列+vector)
Problem Description Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, ...
- sysbench测试
什么是基准测试 数据库的基准测试是对数据库的性能指标进行定量的.可复现的.可对比的测试. 基准测试与压力测试 基准测试可以理解为针对系统的一种压力测试.但基准测试不关心业务逻辑,更加简单.直接.易于测 ...
- dev chart使用
public class LineChartHelp { #region 折线图 /// <summary> /// 创建折线图 /// </summary> public v ...
- 一、maven学习
1.下载(maven 自带Tomcat 命令tomcat:run) 2.配置环境变量(cmd测试 mvn -v) 3.配置config 4.命令 mvn clean (删除target目录) ...