gem griddlerを使用してレールアプリでメールを受信する方法は?
私はこのリンクをたどります:http://sendgrid.com/blog/recoming-email-in-your-rails-app-with-griddler/
私の index.html.erb posts_controller :
投稿
<% if @posts.count > 0 %>
<% @posts.each do |post| %>
<blockquote>
<p><%= post.body %></p>
<small><%= post.email %></small>
</blockquote>
<% end %>
<% else %>
<p><em>Oops, doesn't look like there are any posts yet.</em></p>
<% end %>
私の config/initializer/griddler.rb :
Griddler.configure do |config|
config.processor_class = EmailProcessor # MyEmailProcessor
config.to = :hash # :full, :email, :token
config.from = :email # :full, :token, :hash
# :raw => 'AppName <s13.6b2d13dc6a1d33db7644@mail.myapp.com>'
# :email => 's13.6b2d13dc6a1d33db7644@mail.myapp.com'
# :token => 's13.6b2d13dc6a1d33db7644'
# :hash => { raw: [...], email: [...], token: [...], host: [...],
# name: [...] }
config.reply_delimiter = '-- REPLY ABOVE THIS LINE --'
config.email_service = :sendgrid # :cloudmailin, :postmark, :mandrill, :mailgun
end
私の lib/email_processor.rb :
class EmailProcessor
def self.process(email)
# all of your application-specific code here - creating models,
# processing reports, etc
Post.create!({ body: email.body, email: email.from })
end
end
しかし、インデックス ポスト ビューでは、コールバックから何も取得できません。なぜですか?