gi代码:

https://github.com/gorails-screencasts/action-mailbox-action-text/commit/3aeedc09441696c9489ed6c16c5245a01cad0903


新建一个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

  1. #app/javascript/packs/application.js
  2. #...
  3. +require("trix")
  4. +require("@rails/actiontext")

rails g scaffold Post title:string

rails db:migrate后

  1. #app/models/post.rb
  2. # 这里给post记录挂上关联的actiontext和attachment。
  3. class Post < ApplicationRecord
  4. has_rich_text :body
  5. has_many_attached :attachments
  6. end

rails action_mailbox:install

所有入境的邮件都让posts处理。

  1. #app/mailboxes/application_mailbox.rb
  2. class ApplicationMailbox < ActionMailbox::Base
  3. # routing /something/i => :somewhere
  4. routing :all => :posts
  5. end

rails g mailbox Posts

  1. ..

app/views/posts/_form.html.erb 修改代码,添加richtext,并根据post是否存在,添加删除和返回按钮。

  1. <div class="field">
  2. <%= form.label :title %>
  3. <%= form.text_field :title, class: 'form-control' %>
  4. </div>
  5.  
  6. <div class="form-group">
  7. <%= form.label :body %>
  8. <%= form.rich_text_area :body, class: 'form-control' %>
  9. </div>
  10.  
  11. <div class="form-group">
  12. <% if post.persisted? %>
  13. <div class="float-right">
  14. <%= link_to "Destroy", post, method: :delete, class:'text-danger', data: {confirm: "Are you sure?"}%>
  15. </div>
  16. <% end %>
  17.  
  18. <%= form.submit class: 'btn btn-primary'%>
  19.  
  20. <% if post.persisted? %>
  21. <%= link_to "Cancel", post, class: "btn btn-link"%>
  22. <% else %>
  23. <%= link_to "Cancel", posts_path, class: "btn btn-link"%>
  24. <% end %>
  25. </div>
  26. <% end %>

app/views/posts/index.html.erb 修改代码:

  1. + <td><%= post.body %></td>

app/views/posts/show.html.erb 修改代码:

  1. <div class="page-header">
  2. <%= link_to posts_path, class: 'btn btn-default' do %>
  3. All Posts
  4. <% end %>
  5. <%= link_to edit_post_path(@post), class: 'btn btn-primary' do %>
  6. Edit
  7. <% end %>
  8. <h1>Show post</h1>
  9. </div>
  10.  
  11. <dl class="dl-horizontal">
  12. <dt>Title:</dt>
  13. <dd><%= @post.title %></dd>
  14.  
  15. <dt>Body:</dt>
  16. <dd><%= @post.body %></dd>
  17.  
  18. </dl>
  19.  
  20. <% @post.attachments.each do |attachment| %>
  21. <div><%= link_to attachment.filename, attachment %></div>
  22. <% end %>

配置:

如何保存ActionMailbox inbound HTML email和关于ActionText与ActiveStorage的附加的更多相关文章

  1. salesforce零基础学习(九十三)Email To Case的简单实现

    Salesforce提供了标准的功能来实现通过Email 创建 Case.我们可以设置指定的路由的地址,指定条件的邮件会自动生成到目标salesforce系统的Case数据.Salesforce提供了 ...

  2. 推荐几款我一直在用的chrome插件(下)

    请先看:推荐几款我一直在用的chrome插件(上) 6. Pocket 可以很方便的保存文章.视频等供以后查看,即实现了“Read it later”功能.有了 Pocket,您可以将所有想下次读的内 ...

  3. 如何在ubuntu中启用SSH服务

    如何在ubuntu14.04 中启用SSH服务 开篇科普:  SSH 为 Secure Shell 的缩写,由 IETF 的网络工作小组(Network Working Group)所制定:SSH 为 ...

  4. 怎样使用 GitHub?

    作者:珊姗是个小太阳链接:https://www.zhihu.com/question/20070065/answer/79557687来源:知乎著作权归作者所有,转载请联系作者获得授权. 作为一个文 ...

  5. Http客户端识别的方法

      Http用户识别的机制方法分为如下几种: 1).承载用户身份的HTTP首部 2).客户端IP地址跟踪,根据客户端IP地址进行识别 3).用户登录,用认证方式设别用户 4).使用胖URL,一种在UR ...

  6. Orchard创建自定义表单

    本文链接:http://www.cnblogs.com/souther/p/4520130.html 主目录 自定义表单模块可以用来获取网站前台用户的信息.自定义表单需要与一个内容类型结合使用.它可以 ...

  7. ylbtech-dbs-m-QQ邮箱

    ylbtech-dbs:ylbtech-dbs-m-QQ邮箱 -- =============================================-- DatabaseName:QQ-Em ...

  8. 转:怎么使用github(通俗易懂版)

    转:  https://www.zhihu.com/question/20070065 作者:珊姗是个小太阳链接:https://www.zhihu.com/question/20070065/ans ...

  9. 版本控制工具--GIT 基本命令(1)

    一.安装GIT,在官网上下载安装即可(下面模拟环境是window7) 二.基本操作: 1.创建GIT库: ①先使用mkdir命令创建一个空目录,再使用git init将该目录变成GIT库,会在该目录下 ...

随机推荐

  1. 安装ceilometer

    在控制节点上执行 #!/bin/bash MYSQL_ROOT_PASSWD='m4r!adbOP' GNOCCHI_PASSWD='gnocchi1234!' CEILOMETER_PASSWD=' ...

  2. python之pip使用技巧

    pip 镜像临时使用:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider永久:直接在user目录中创建一个pip目录:C: ...

  3. 【miscellaneous】海康威视监控摄像头实现web端无插件监控实拍效果

    [rtsp]海康威视监控摄像头实现web端无插件监控实拍效果 详细介绍参见:http://live.cuplayer.com/RtspCameraLive.html web端无须装插件(支持PC,安卓 ...

  4. python中的FQA (python 学习篇 1)

    Q:1.  "  if __name__=='__main__'   "  这句是什么意思,可以不加吗? A:   如果单独运行该文件,则该模块的内容会被执行: 若运行的文件引用该 ...

  5. Highest Frequency Letters

    Given a list of strings, output the most frequent characters that are in the same group as the lette ...

  6. 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 ...

  7. Hinton等人最新研究:大幅提升模型准确率,标签平滑技术到底怎么用?

    Hinton等人最新研究:大幅提升模型准确率,标签平滑技术到底怎么用? 2019年07月06日 19:30:55 AI科技大本营 阅读数 675   版权声明:本文为博主原创文章,遵循CC 4.0 B ...

  8. 命名规范 camel case, pascal case, hyphen

    2019-11-08  refer : https://ux.stackexchange.com/questions/43174/update-vs-modify-vs-change-create-v ...

  9. 《深入实践C++模板编程》之六——标准库中的容器

    1.容器的基本要求 a.并非所有的数据都可以放进容器当中.各种容器模板对所存数据类型都有一个基本要求——可复制构造.将数据放进容器的过程就是通过数据的复制构造函数在容器内创建数据的一个副本的过程. b ...

  10. C# List.sort排序(多权重,升序降序)

    很多人可能喜欢Linq的orderBy排序,可惜U3D里面linq在Ios上会报错,所以就必须使用list的排序. 其实理解了并不难 升序降序比较 sort有三种结果 1,-1,0分别是大,小,相等. ...