Using gmail gem with Rails 4 -
Using gmail gem with Rails 4 -
i'm trying utilize nu7hatch/gmail gem rails , i've run problems. rule out conflict rest of app started new c9.io instance absolute minimum of code , still got same problem. changed basic rails scaffold follows:
gemfile (added):
gem 'gmail'
routes.rb (added):
root 'welcome#index'
welcome_controller.rb:
class welcomecontroller < applicationcontroller def index gmail.connect("username", "password") |gmail| @emails=gmail.inbox.find(:unread) end end end
index.html.erb (view):
<%= @emails.each |email| %> <p><%= email.subject %></p> <% end %>
when visit root of app, next error: cannot load such file -- mime/message
rails tell me error refers line: @emails=gmail.inbox.find(:unread)
does have ideas how can create work please?
i'm not sure if you've answered or not, thought add together found. think right way set in config/initializer omniauth does. i'm using gem little personal project so, decided build gmail_client
model, , tell controller utilize that.
//gmail_client.rb require 'active_model' class gmailclient include activemodel::model def build gmail.connect!('some_email', 'some_password') end end
i decided go activemodel because didn't want sort of thing stored in db.
and in controller like:
//some_controller ... def index gmail = gmailclient.new.build @emails = gmail.inbox.find(:unread) end ...
ruby-on-rails ruby-on-rails-4 rubygems gmail
Comments
Post a Comment