Chris Oliver

Joined

290,590 Experience
86 Lessons Completed
296 Questions Solved

Activity

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. :)

Posted in Multi-event .ICS file generation?

I haven't, but it definitely looks like ri_cal hasn't been touched in several years. I'd probably have to recommend iCalendar just based on that but their documentation and API don't appear to be the cleanest.

Wish I had more information for you on it, but I haven't had to create .ics files before. Maybe that'll make for a good screencast.

Posted in Liking Posts Discussion

The easiest way is to use a counter cache column. It can keep track of how many likes each post has and saves it on the post so that you can quickly and easily query that. There's an old Railscast on it that I'd recommend: http://railscasts.com/episo...

You could also do it with a join and a group by query, but a counter cache will let you sort the information at any time quickly.

Posted in Multi Model Sign-up Wizard

Are you trying to create a company before they create a user on sign up?

What I do in this case is use the user registration form and do fields_for :company inside of it. That way you can't create a company without attaching it to a User. I can ask for teh company information first, but in the same form I also submit the user details which save the company and associate the user as the "Owner" of the company.

Am I following you correctly?

Looks like you can if you add the "dateext" option. More details here: http://www.thegeekstuff.com...

Posted in Pagination with will_paginate Discussion

Great idea! I've done that in the past when I wasn't sure why it wasn't rendering and that helped a lot. :)

Posted in Refactoring Controller Methods Discussion

That's definitely an option. I prefer not to because the QUESTIONS are related to business logic regarding some type of model and the SMS class just purely contains logic on how to send an SMS. This way it's separated from other concerns and is purely on its own. You could extract this out into a library if you wanted to share it between apps for example and you wouldn't have the QUESTIONS and other dependencies.

Posted in Refactoring Controller Methods Discussion

Oh yep, you're right. It's easy to miss stuff like that when you can't actually execute the code.