如何保存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库,会在该目录下 ...
随机推荐
- 安装ceilometer
在控制节点上执行 #!/bin/bash MYSQL_ROOT_PASSWD='m4r!adbOP' GNOCCHI_PASSWD='gnocchi1234!' CEILOMETER_PASSWD=' ...
- python之pip使用技巧
pip 镜像临时使用:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider永久:直接在user目录中创建一个pip目录:C: ...
- 【miscellaneous】海康威视监控摄像头实现web端无插件监控实拍效果
[rtsp]海康威视监控摄像头实现web端无插件监控实拍效果 详细介绍参见:http://live.cuplayer.com/RtspCameraLive.html web端无须装插件(支持PC,安卓 ...
- python中的FQA (python 学习篇 1)
Q:1. " if __name__=='__main__' " 这句是什么意思,可以不加吗? A: 如果单独运行该文件,则该模块的内容会被执行: 若运行的文件引用该 ...
- Highest Frequency Letters
Given a list of strings, output the most frequent characters that are in the same group as the lette ...
- selenium 鼠标,键盘操作
1.打开和关闭网页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/usr/bin/env python # -*- coding:u ...
- Hinton等人最新研究:大幅提升模型准确率,标签平滑技术到底怎么用?
Hinton等人最新研究:大幅提升模型准确率,标签平滑技术到底怎么用? 2019年07月06日 19:30:55 AI科技大本营 阅读数 675 版权声明:本文为博主原创文章,遵循CC 4.0 B ...
- 命名规范 camel case, pascal case, hyphen
2019-11-08 refer : https://ux.stackexchange.com/questions/43174/update-vs-modify-vs-change-create-v ...
- 《深入实践C++模板编程》之六——标准库中的容器
1.容器的基本要求 a.并非所有的数据都可以放进容器当中.各种容器模板对所存数据类型都有一个基本要求——可复制构造.将数据放进容器的过程就是通过数据的复制构造函数在容器内创建数据的一个副本的过程. b ...
- C# List.sort排序(多权重,升序降序)
很多人可能喜欢Linq的orderBy排序,可惜U3D里面linq在Ios上会报错,所以就必须使用list的排序. 其实理解了并不难 升序降序比较 sort有三种结果 1,-1,0分别是大,小,相等. ...