Ashley Engelund

Joined

2,560 Experience
24 Lessons Completed
0 Questions Solved

Activity

Posted in User Onboarding Progress Bar Discussion

Implementing this is something that needs to happen soon in the app I'm working on, so your timing is perfect!

It covers nearly exactly what we need to do. :-)

Thanks!

Posted in Help request - Not sure how to implement an idea.

The easiest way to do this is to have your front-end use Javascript to send the info to your Rails app. The Javascript will send it to your Rails app when it detects your user leaving the "box" for that pill on that day. (It'll be an 'on change' -type method in Javascript.)

If you don't have any experience with Javascript, you can read the Rails Guide (https://guides.rubyonrails.org/working_with_javascript_in_rails.html) and also watch the GoRails episodes that walk you through using Javascript + Rails. Here's one: https://gorails.com/episodes/clean-javascript-with-data-behavior) . Even though there have been improvements in Javascript & Rails+Javascript since that episode, the fundamentals are still the same. It -- and the episodes in that series -- explains the concepts and interactions well.

If you do have Javascript experience, then you can look for the GoRails episodes that use Vue or whatever framework you like. And I definitely recommend the Stimulus episodes, too.

(And BTW, it just so happens that I take a lot of pills to keep my body upright and functioning. So I think I have a decent idea of what your UI might look like. :-) )

Posted in Help request - Not sure how to implement an idea.

Just trying to understand things:

Your UI is basically a calendar. Each day (each box in the calendar) a user can enter how many pills s/he's taken for a particular medication.

Each time the user moves out of a day (by tabbing or pressing enter to move to the next day, for example), the number entered is saved to the db.

Is that right?

In other words, you don't want the user to have to explicitly click on a SAVE button.

Peter --
I didn't notice it before, but in your code:

def find_students_who_share_classes
    in_math = Student.all_in_klass(@math)
    in_sci = Student.all_in_klass(@sci)
    in_math.merge(in_sci)
    return in_math.distinct
end

you're using a merge which will give you an AND and not the OR that you want.

Glad to have helped! :-)
(Some folks would rather write that scope as a class method, of course)
If the number of "classes" varies, then you can call that scope/method as many times as needed, of course.

And ya -- I know what it's like to have to translate a domain/problem so that you can talk about it, while not losing any important information in translation either way.

Hm. This is straightforward if you use scopes but I'm not sure that's what you're looking for.

class Student < ApplicationRecord

  has_many :enrollments

  has_many :klasses, through: :enrollments

  scope :all_in_klass, ->(k){ joins(:klasses).joins(:enrollments).where(enrollments: {klass: k} ).distinct }

end

then:

in_math = Student.all_in_klass(math)
=> Student Load (0.2ms)  SELECT  DISTINCT "students".* FROM "students" INNER JOIN "enrollments" ON "enrollments"."student_id" = "students"."id" INNER JOIN "klasses" ON "klasses"."id" = "enrollments"."klass_id" INNER JOIN "enrollments" "enrollments_students" ON "enrollments_students"."student_id" = "students"."id" WHERE "enrollments"."klass_id" = ? LIMIT ?  [["klass_id", 1], ["LIMIT", 11]]
#<ActiveRecord::Relation [#<Student id: 1, name: "Alice", created_at: "2019-02-22 00:05:20", updated_at: "2019-02-22 00:05:20">, #<Student id: 2, name: "Bob", created_at: "2019-02-22 00:05:29", updated_at: "2019-02-22 00:05:29">, #<Student id: 3, name: "Charlie", created_at: "2019-02-22 00:05:36", updated_at: "2019-02-22 00:05:36">]>

in_sci = Student.all_in_klass(science)
  Student Load (0.2ms)  SELECT  DISTINCT "students".* FROM "students" INNER JOIN "enrollments" ON "enrollments"."student_id" = "students"."id" INNER JOIN "klasses" ON "klasses"."id" = "enrollments"."klass_id" INNER JOIN "enrollments" "enrollments_students" ON "enrollments_students"."student_id" = "students"."id" WHERE "enrollments"."klass_id" = ? LIMIT ?  [["klass_id", 2], ["LIMIT", 11]]
=> #<ActiveRecord::Relation [#<Student id: 1, name: "Alice", created_at: "2019-02-22 00:05:20", updated_at: "2019-02-22 00:05:20">, #<Student id: 2, name: "Bob", created_at: "2019-02-22 00:05:29", updated_at: "2019-02-22 00:05:29">]>


in_math_and_sci = in_math & in_sci
=> [#<Student id: 1, name: "Alice", created_at: "2019-02-22 00:05:20", updated_at: "2019-02-22 00:05:20">, #<Student id: 2, name: "Bob", created_at: "2019-02-22 00:05:29", updated_at: "2019-02-22 00:05:29">]

I think the basic issue is that you want an AND query, but what you're getting is an OR query. IOW, the query may actually be 'where klass.id is math.id OR science.id' .
I think it's doing a 'where klass.id IN (math.id, science.id)...' but I don't have time to check right now.

Posted in Server Administration with Cockpit Discussion

This is just the sort of monitoring utility I've been looking for! I've been looking for something that is easy to install and gives me basic monitoring. So glad you did this episode; Cockpit looks like a great possibility!

Posted in Sharing on social network

FWIW -- Here's the slightly more generalized version of the code that I'm using:

<%= javascript_tag do %>

  // update the meta tags, since turbolinks will NOT update them

  $(document).on('ready page:change', function () {
     $("meta[property='og\\:title']").attr("content", "<%= yield_or_default(:og_title, t('meta.og.title')) %>");
     $("meta[property='og\\:description']").attr("content", "<%= yield_or_default(:og_description, t('meta.description')) %>");
    $("meta[property='og\\:url']").attr("content", "<%= yield_or_default(:og_url, ENV['SITE_HOME_URL']) %>");
    $("meta[property='og\\:image']").attr("content", encodeURIComponent("<%= yield_or_default(:og_image, social_meta_app_image) %>") );
    $("meta[property='og\\:text']").attr("content", "<%= yield_or_default(:og_text, t('meta.description')) %>");
  });

<% end %>

I have a helper method social_meta_app_image to return the url for a 'devaault' image , and the very common helper method yield_or_default(...) that is the standard "if there's no content_for:... then use this default value.

(I'm not sure that I really need the encodeURIComponent call.)

This lets me change the values with each view by just defining a content_for: ... or provide for the values.

Posted in Error monitoring and notification for RoR

the fact that errbit uses mongo does not make me happy. (or at least that it's not made such that you can use whatever backend you want) and that you apparently need to run a job to 'clear out' errors or else errbit will slow down.... :-( (I don't have any perspective on what # of errors you need to be generating for that to be an issue, but I've come across enough mentions of having to do that 'clearing out' to make me suspect it's not all that many.)

Thanks for the good & quick feedback. (and that is why it's worth paying you some of my $ !)

Posted in Error monitoring and notification for RoR

Starting simple is definitely the way to go with this project. Sounds like exception notification will do just fine for now. Hopefully it won't be a "lot" of exceptions. :-)

Ya, it looks like errbit requires a separate app. Would be fine if I was monitoring many apps, but that is definitely not the case with this.

Posted in Error monitoring and notification for RoR

I'm helping on a small RoR app. I need to set up error monitoring for it. errbit or exception_notification both look pretty good. This is a small app right now (< 200 users with logins, probably only a dozen logged in at any 1 time right now), so the needs are modest.

It’s for a non-profit, so there’s 0 money. It’s running on DigitalOcean (Ubuntu).

The project uses PivotalTracker & Slack, so it’d be fantastic to have hooks/plug-ins to interact with those, but that’s not a requirement.

Any recommendations for either ruby gems or Unix tools?

(Been quite a while since I needed to set this kind of thing up.)

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.