Category: daily learning

  • CoffeeScript event handlers only working after page refresh

    I was able to find a resolution on StackOverflow to fix an event handler. I initially opted to added $(document).ready(…) and $(document).on(‘page:load’, …) handlers as follows: ready = -> $(‘form’).on ‘click’, ‘.clickable_class’, (event) -> # doStuff # added lines: $(document).ready(ready) $(document).on(‘page:load’, ready) However, another answer recommended adding the jquery-turbolinks instead. Browsing the source code, it…

  • ActionDispatch::Cookies::CookieOverflow and Rails 4.1

    Ran into this error when adding a new route. Turns out that I was stuffing the model.errors into the alert flash, making the session cookie relatively huge. While stuffing all that data into the cookie wasn’t intended, it made me notice that we were storing the session in a cookie instead of a database like…

  • has_many :through, scoped to a value on the other side of the :through relationship

    Here goes another round of wrapping my head around what rails associations are looking for. This time, I’m trying to scope a collection on the other side of a has_many :through to an attribute on that model. Contrived exhibit A: class Gym < ActiveRecord::Base # gym has a boolean "open" end class TrainerGym < ActiveRecord::Base…