Chris Oliver

Joined

290,800 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in File Uploads with Refile Discussion

CSV upload is definitely a topic I need to cover soon. I usually don't save the CSV files so I traditionally just use a file_field and let the file get deleted after the request is done in most cases.

Refile could work for storage of the CSVs though and then the model could access the file and parse it as necessary if you want to store the CSVs permanently.

Posted in File Uploads with Refile Discussion

Definitely a worthy discussion to be had with the author of the gem.

Posted in jQuery UJS and AJAX Discussion

I'm using patch because we want to modify the record. You don't ever want a GET request to update a record because that would be unsafe so either a PUT or a PATCH is best in this case.

Posted in File Uploads with Refile Discussion

Yep, shouldn't be a problem. You'll just skip the image processing parts.

Posted in Button Loading Animations with jQuery UJS Discussion

Unfortunately you can't because it doesn't allow HTML inside of it.

Posted in Fragment Caching And oEmbed Discussion

You could remove the expires_in option and set up a nightly cron job to expire the fragments and then immediately request the page instead. When you do it with an expiration like this, you can't know when it expires exactly so it would be hard to expire and then request the page again.

Well shoot. That's definitely missing audio. I may not have the original audio to get that fixed unfortunately. Looks like I'm just explaining that you can set the anchor and your emails can link to and highlight the specific element on the page when you click the link.

Posted in Forum Series Part 6: Search with Ransack Discussion

You can do autocomplete by having it query the URL for JSON response each time someone types a character. My suggestion is to try hooking it up with jQuery UI's autocomplete. http://jqueryui.com/autocom...

Posted in Search functionality for the screencasts

It looks like you're trying to do a string comparison on the created_at timestamp. I think you want to use created_at_gteq instead of created_at_cont in your search form.

Posted in Search functionality for the screencasts

Ah interesting. How come you're going with a custom search?

Posted in Search functionality for the screencasts

Like this? :) https://gorails.com/episodes/forum-search-with-ransack

I can't remember if I talk about going through multiple models, but it's about as simple as making your search field names include the two model names.

Posted in Tracking Rails App Usage with Analytics

That looks super cool. There's also another gem called Ahoy that I've heard good things about but I haven't used it and it doesn't look to have a nice dashboard (from what I saw at a glance).

At One Month, we use segment.io to send metrics to a bunch of different services. One of our most important ones is Mixpanel where we build and measure all our funnels. Admittedly I don't do much tracking other than Google Analytics on GoRails so the data I get back isn't super useful.

I think segment.io is really awesome and you can just tell it to pipe your metrics wherever you want and it gets syndicated for you. All you have to do is build it once and all your services (whatever ones you want) receive the data.

Of course redis_analytics or ahoy make a lot of sense if you want to keep it all internal without using 3rd party services.

Posted in Updating Nested Form / Model Attributes

I just posted an answer that hopefully works for you. The create action is where you want to add the logic to set the role, active, and default_role attributes. Since your form submits a role object already, we can assume this is the last one and update it to have the default attributes of ( :role => 'owner', :active => 1, :default_role => 1 etc.).

Make sense?

Posted in Refactoring Controller Methods Discussion

Fetch is really great because it can throw an exception when your key is missing rather than just calling undefined methods on nil later. It's great for that but it also is a little cleaner than the "or" like you mentioned.

Check out Janus (https://github.com/carlhuda.... It's a collection of Vim plugins that give it some pretty great defaults and can save you a lot of time learning Vim at the beginning.

Posted in Multi-event .ICS file generation?

I wonder if maybe you need to call super() at the beginning of the initialize method so the Icalendar gets initialized properly.

Posted in Multi-event .ICS file generation?

Hmm, can you post the stacktrace?

Posted in Multi-event .ICS file generation?

Awesome! That's not too bad.

I believe you could extract this out into its own class to clean up your controller a bit:

def ics_export
  @myevents = Event.all

  respond_to do |format|
    format.html
    format.ics { render text: Ical.new(@myevents).to_ical }
   end
end
# app/models/ical.rb
class Ical < Icalendar::Calendar
  def initialize(events)
    events.each do |myevent|
      event = Icalendar::Event.new
      event.dtstart = myevent.event_date
      event.summary = myevent.name
      add_event(event)
    end
    publish
  end
end

Note that in this file you don't need to call cal. on add_event and publish since you've inherited those methods and you're inside the object. I also pulled out publish to the end so it only gets called once. I think that doesn't need to be run each loop but maybe it does.

Posted in video about sortable lists

I've always used acts_as_list and been really happy with it. https://github.com/swanandp/acts_as_list

Posted in Bootstrap Devise User create, edit and sessions new

This is awesome Jay! Thanks for posting it. I definitely did cut out some of this because I wanted to focus on Devise rather than Bootstrap. This will come in handy for a lot of people I'm sure. :)