宝石不工作的时候

时间:2014-02-07 04:15:51

标签: devise ruby-on-rails-4 haml whenever

每当宝石不工作......当我只是填写联系我们表格时,它会在生产和开发环境中发送电子邮件....但是每当宝石不发送这个......什么是正在发生的.....?

schedule.rb

every 1.minutes do
    runner "Forest.weekly_update", :environment => :development
end

every 2.minutes do
    runner "Forest.welcome_user", :environment => :development
end

Controller forests_controller.rb

def self.weekly_update
        @forests = Forest.all
        @forests.each do |u|
            #UsersMailer.weekly_mail(u.email).deliver
            UserMailer.welcome_user(u.id).deliver
        end
    end
def create
        @forest = Forest.new(forest_params)
        #@today = Date.today
        #respond_to do |format|
        if @forest.save
            # if (@today + 7.days == Date.today) 
            #    redirect_to main_index_path
            # else
            #     redirect_to root_path
            # end

            #UserMailer.welcome_user(@forest).deliver

            redirect_to main_index_path
            #format.html { redirect_to @forest, notice: 'Your Message send successfully.' }
            #format.json { render action: 'show', status: :created, location: @forest }
        else
            render forests_new_path
            #format.html { render action: 'new' }
            #format.json { render json: @forest.errors, status: :unprocessable_entity }
        end
    end

user_mailer.rb

类UserMailer<的ActionMailer ::基

  default from: "no-reply@forestbankfoundation.org"

  def welcome_user(forest)
    @forest = forest
    mail(to: "tayyabz@stis.pk", subject: "No-Reply", body: @forest.body, from: @forest.email)
  end

end

我无法理解这个问题......有人能搞清楚......?

0 个答案:

没有答案