小编xps*_*15z的帖子

535-5.7.8不接受用户名和密码

我有一个联系表单,提交后我收到Net :: SMTPAuthenticationError 535-5.7.8 Username and Password not accepted

它指向联系人控制器中的创建操作 ContactMailer.new_contact(@contact).deliver

我重新启动了服务器.我尝试了https://accounts.google.com/DisplayUnlockCaptcha.

我在发展中.

联系控制器:

 def new
      @contact = Contact.new
    end

    def create
      @contact = Contact.new(params[:message])
      if @contact.valid?
        ContactMailer.new_contact(@contact).deliver
        flash[:notice] = "Message sent! Thank you for contacting us."
        redirect_to root_url
      else
        render :action => 'new'
      end
    end
  end
Run Code Online (Sandbox Code Playgroud)

Development.rb:

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    domain:               'gmail.com',
    user_name:            'username@gmail.com',
    password:             'password',
    authentication:       'plain',
    enable_starttls_auto: true  }

  config.action_mailer.default_url_options = { …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

25
推荐指数
6
解决办法
6万
查看次数

使用Magnific Popup创建动作以使配置文件照片默认

我可以使用帮助创建一个样式表来覆盖Magnific Popup中的默认样式表(https://github.com/joshuajansen/magnific-popup-rails).

我有代码供用户default_profile_id从他们上传的图片中选择.我遇到的问题是我需要能够让当前用户从他们的页面做出决定的代码.例如,当前用户将鼠标悬停在他们的照片上,并在其上显示"制作个人资料照片"文本(https://s18.postimg.cc/arl81snll/mouse.jpg).我不知道如何创建样式表或修改我所拥有的样式,以便此操作可以正常工作.

任何帮助将这个动作添加到照片将非常感激.

照片控制器:

 def new 
    @photo = Photo.new
  end

  def create
    @photo = Photo.new(params[:photo])
    @photo.user = current_user
    if @photo.save
      flash[:notice] = "Successfully created photos."
      redirect_to :back
    else
      render :action => 'new'
    end
  end

  def resize(width, height, gravity = 'Center')
    manipulate! do |img|
      img.combine_options do |cmd|
        cmd.resize "#{width}"
        if img[:width] < img[:height]
          cmd.gravity gravity
          cmd.background "rgba(255,255,255,0.0)"
          cmd.extent "#{width}x#{height}"
        end
      end
      img = yield(img) if block_given?
      img
    end
  end
  def edit
    @photo = Photo.find(params[:id]) …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery ruby-on-rails magnific-popup

17
推荐指数
1
解决办法
932
查看次数

Heroku在发送电子邮件时超时

我在Heroku上使用自定义域名,我有Redis附加组件.我需要帮助了解如何为电子邮件通知创建后台工作程序.用户可以互相收件箱,我希望向用户发送收到的每封新邮件的电子邮件通知.我有开发工作的通知,但我不擅长创建Heroku所需的后台作业,否则服务器会超时.

消息控制器:

  def create
    @recipient = User.find(params[:user])
    current_user.send_message(@recipient, params[:body], params[:subject])
    flash[:notice] = "Message has been sent!"
    if request.xhr?
        render :json => {:notice => flash[:notice]}
    else
        redirect_to :conversations
    end
  end
Run Code Online (Sandbox Code Playgroud)

用户模型:

def mailboxer_email(object)
    if self.no_email
      email
    else
        nil
    end
end
Run Code Online (Sandbox Code Playgroud)

Mailboxer.rb:

Mailboxer.setup do |config|

  #Configures if you applications uses or no the email sending for Notifications and Messages
  config.uses_emails = false

  #Configures the default from for the email sent for Messages and Notifications of Mailboxer
  config.default_from = "no-reply@domain.com"

  #Configures the methods …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku redis

13
推荐指数
2
解决办法
384
查看次数

显示条纹信用卡的最后4位数字

我试图弄清楚如何使用Stripe显示用户默认卡的最后4位数.我提出的代码不会显示它.

有没有人知道如何解决我的问题?

控制器:

  def last4
  customer = Stripe::Customer.retrieve(user.subscription.stripe_customer_token)
  card = customer.cards.retrieve(user.subscription.stripe_card_id)
  charge = Stripe::Charge.retrieve(user.subscription.stripe_charge_id)
  self.last_4_digits = charge.card.last4
  end
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails stripe-payments

3
推荐指数
1
解决办法
1565
查看次数

URI :: InvalidComponentError:坏组件(预期的主机组件):localhost:3000

我不知道出了什么问题,但在运行时NewsletterMailer.weekly("username-here@gmail.com").deliver我在控制台中得到错误URI::InvalidComponentError: bad component(expected host component): localhost:3000

我仔细检查我的设置,一切似乎都很好.这是错误的完整输出:

    from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:605:in `check_host'
    from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:646:in `host='
    from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:195:in `initialize'
    from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:141:in `new'
    from /Users/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/uri/generic.rb:141:in `build'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:206:in `absolute_url_base'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:192:in `ensure_absolute_url'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:180:in `block in make_image_urls_absolute'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:179:in `make_image_urls_absolute'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:57:in `block in execute'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:80:in `block in adjust_html'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `tap'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/roadie-2.4.3/lib/roadie/inliner.rb:79:in `adjust_html'
... 10 levels...
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/actionpack-4.0.0.rc1/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0.rc1/lib/active_support/callbacks.rb:392:in `_run__4195001508967449441__process_action__callbacks'
    from /Users/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.0.rc1/lib/active_support/callbacks.rb:80:in `run_callbacks' …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

2
推荐指数
2
解决办法
4169
查看次数