Liz Bayardelle

Joined

120 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Sortable Drag and Drop Discussion

Hi Chris,

This is such a useful video! With a little help from your friendly neighborhood GoRails Slack channel I got it (mostly) working, but for some reason it's not serializing correctly. According to my server log, it is sending PATCH data to the database:

Started PATCH "/tasks/sort" for 127.0.0.1 at 2018-10-20 11:16:06 -0700
Processing by TasksController#sort as */*
  Parameters: {"task"=>["2", "8"]}
  User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ?  [["id", 1], ["LIMIT", 1]]
  ↳ /Users/lizbayardelle/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98
  Task Update All (0.2ms)  UPDATE "tasks" SET "position" = 1 WHERE "tasks"."id" = ?  [["id", 2]]
  ↳ app/controllers/tasks_controller.rb:27
  Task Update All (0.1ms)  UPDATE "tasks" SET "position" = 2 WHERE "tasks"."id" = ?  [["id", 8]]
  ↳ app/controllers/tasks_controller.rb:27
Completed 200 OK in 3ms (ActiveRecord: 0.5ms)

But for some reason it always stays the original order on refresh. Any hints as to what could be going wrong?

The only difference between my app and the example app is that I had to have the .sortable act on a class (.taskWrapper not #taskWrapper) because I have the tasks in a partial that's being rendered more than one place on the page. Could that be affecting it?

Posted in Direct Uploads with ActiveStorage Discussion

I'm trying to do this using AWS S3 and am getting a console error: POST http://localhost:3000/rails/active_storage/direct_uploads 500 (Internal Server Error). Any steps I should check? The only thing I can think of is that it could have something to do with the modifications I used for S3 instead of DigitalOcean?

Posted in Recurring events with the ice_cube gem Discussion

Gaaahhh! Thank you! That was driving me crazy.

Posted in Recurring events with the ice_cube gem Discussion

For some reason the simple_calendar gem messed with a bunch of the CSS on my site (e.g. all my links now have a black background on hover, etc.). Any hints on how to avoid this?

Posted in Subscriptions with Stripe Discussion

Thank you. All better. #moronpoints

Posted in Subscriptions with Stripe Discussion

I am learning so much from this Episode! One thing, after putting my secret/public keys in my environments/development.rb as recommended at 29:34ish, I get an uninitialized constant ActionView::CompiledTemplates::STRIPE_PUBLIC error trying to access the subscriptions#new page. Is this a common problem? It seems like I must be doing something simple wrong...

I'm not sure if this is the official "Rails" way, but the way I did this in a recent project was to create an array:

@products_array = []
@products.each do |product|
            @products_array << product.title
    end

And then to use this array as the collection in my simple form:

<%= b.input :product, collection: @products_array %>

As I said, there might be a Railsier way to do this, but this worked in my case. Hope it helps!

Posted in Send an Email On a Date Specified in a Database Column

I have what I think is a working setup to send emails via Delayed_Job. However, I haven't received my test email and it isn't practical to wait for more to happen with a delay of days. I need to figure out:

  1. What's wrong that's causing the email not to send.
  2. How to test it without waiting days at a time.

I'm new to Delayed_Job, so pardon the newbie mistakes.

Here's the model that includes the send_reminder_emails method. They were fully functional without the delay bit, so at least I know that much works:

class Reminder < ActiveRecord::Base
  belongs_to :user
  before_save :create_mail_date
  after_save :send_reminder_emails
  extend FriendlyId
  friendly_id :name, use: [:slugged, :finders]

  def create_mail_date
    @schedule = IceCube::Schedule.new(self.date)
    case self.repeating
    when "Weekly"
        @schedule.add_recurrence_rule(
            IceCube::Rule.weekly
        )
    when "Monthly"
        @schedule.add_recurrence_rule(
            IceCube::Rule.monthly.day_of_month(self.date.mon)
        )
    when "Yearly"
        @schedule.add_recurrence_rule(
            IceCube::Rule.yearly.day_of_year(self.date.yday)
        )
    end
    if self.repeating
        self.date = @schedule.next_occurrence(Time.now)
    end
    self.mail_date = self.date - 7.days
  end

  private

  def send_reminder_emails
      if self.reminder
            RemainderMailerJob.set(wait_until: self.mail_date).perform_later(user, remainder)  ##this line is the issue
            #ReminderMailer.delay(run_at: self.mail_date).reminder_send(self.user, self)ow
         self.create_mail_date   ##this is another solution I've tried
     end
  end
  handle_asynchronously :send_reminder_emails

end

The references to schedule are via the Ice_Cube gem and all of the date stuff has been tested via my console and is working. Here is my reminder_mailer.rb:

class ReminderMailer < ApplicationMailer
  default from: "man@manlyartofbbq.com"

  def reminder_send(user, reminder)
    @user = user
    @reminder = reminder

    mail(to: user.email, subject: "Reminder! #{reminder.name} is fast approaching!")
  end
end

I installed Delayed_Job step by step from their readme for Rails 4. Any help getting the delayed part of this mailer ironed out is appreciated!