Brent C


780 Experience
0 Lessons Completed
0 Questions Solved


Posted in Introduction to Importing from CSV Discussion

Thanks for a great tutorial on CSV's it's just what I needed. As an aside, I was recently going through my gems and noticed FasterCSV as a dependency in a couple of them. Have you had a chance to play with it much?

Posted in Importing datasets. Recommendations?


Posted in Javascript frameworks videos?

If I had a vote on this I would say Ember because Yehuda Katz is crazy smart and it feels more natural using Ember CLI with Rails (IMO) AND the project isn't controlled by a self-serving corporation (Google or Facebook) Still, that being said React looks wicked cool and React Native has piqued my interest.

But yeah I second Brian's request

Posted in Dynamic Active Record Associations?

Ok, this is much better now! THANK YOU.
What should I do with the old join table? Should I create a migration to destroy it? Or is there a preferred solution?

Posted in Importing datasets. Recommendations?

I have a few datasets that I need to import into my rails app. They vary from 100 records to 5000 which will span across a few models with various associations.

Q.1: I can cleanse the data prior to importing... Any recommendations of data type: CSV, Excel, Tab delimitated, comma separated, etc?

Q.2: Any gems, or techniques that are common use or best practice or should I write a custom rake/chron task?

Posted in Dynamic Active Record Associations?

Ok, good to know. From your description it sounds relatively painless -I will make the necessary modifications. As it applies to my first question, I would then just add a column event_prices to my new Model "EventEventType" (poor naming, I know) then setup the proper associations. Sounds like a better longterm plan.

Posted in Other intermediate-advanced ruby/rails websites?

Also, for some practice/challenges checkout and :)

Posted in Dynamic Active Record Associations?

Thanks Bob and Chris.

Bob, this was the exact clarity I was looking for -Thank you.

Chris, I am not a fan of my has_and_belongs_to_many relationship infact it has caused me pain in other areas (it was put into the project early on). However, those pressing pains have been resolved one way or another. The question now is whether or not I should refactor it and create a has_many :through? A bit of plumbing has been put into place and I will definitely need to spend sometime if I refactor. Is it worth it? Would you consider has_and_belongs_to_many almost a code smell?

Posted in Dynamic Active Record Associations?

Trying to wrap my head around the best way to handle this.

I have an Event Model that has_and_belongs_to_many :event_types
in my Event model I currently have a column for price..

However, what I want to do is have a price for each event_type for this particular Event not just one price for the Event.

So when a user creates a new Event based on the event_type selections they make (checkboxes) I would use javascript to display a new input field for each of those selections. The JS isn’t the issue, What I’m struggling with is seeing the big picture.

Do I create another model, do I need to change my has_and_belongs_to_many to a has_many through, do I make a polymorphic association? Not sure the right path and just need a point in the right direction.


Posted in Multi-event .ICS file generation?

Thanks Chris, super() did the trick.

Posted in Multi-event .ICS file generation?

icalendar (2.2.2) lib/icalendar/component.rb:35:in `ical_properties'
icalendar (2.2.2) lib/icalendar/component.rb:26:in `to_ical'
app/controllers/events_controller.rb:74:in `block (2 levels) in ics_export'
actionpack (4.1.1) lib/action_controller/metal/mime_responds.rb:258:in `call'
actionpack (4.1.1) lib/action_controller/metal/mime_responds.rb:258:in `respond_to'
app/controllers/events_controller.rb:72:in `ics_export'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'

Posted in Multi-event .ICS file generation?

This is a much nicer implementation! However, I am running into an error and can't figure out what is happing here...

undefined method `keys' for nil:NilClass

I am not using any method with "keys" in it. But I did notice iCalendar is so perhaps it has Something to do with the inheritance?


Posted in Multi-event .ICS file generation?

OK after digging around some I decided to dive head into iCalendar. It wasn't to bad just had poor documentation so I had to read the gems codebase to get a feel for what was happening under the hood. Here is my solution for generating multi-event ics files using iCalendar.

I defined a custom method in my Events Controller:

def ics_export
  @myevents = Event.all
  respond_to do |format|
    format.ics do
      cal =
      @myevents.each do |myevent|
         event =
         event.dtstart = myevent.event_date
         event.summary =
       render :text =>  cal.to_ical 

Posted in Multi-event .ICS file generation?

Thanks Chris.

Yeah, I'm not thrilled with either option. Im going to dig around, might be easier to design a custom solution... or not, we'll see.

"Maybe that'll make for a good screencast."
Haha, It sure would, right about now!

Posted in Multi-event .ICS file generation?

Any suggestions for generating an .ICS calendar file containing multiple events from my models? Any experience with Gems(iCalendar vs Ri_cal), or anyone know of good blogposts, etc. detailing the process?


Posted in Best way to grant a user specific permissions

Absolutely, this is exactly what I was trying to wrap my head around.

Thanks a ton Chris for the clear and straight forward explanation. :)

Posted in Best way to grant a user specific permissions

Trying to determine which way I should handle this.

Normal User adds a post to our system, he then has the ability to update and delete this post. In the future he may assign other users the ability to edit, delete, update etc.

Should I create a has_many / belongs_to relationship between the user and post or should I handle this through roles via CanCanCan? Or both?


Posted in jQuery UJS Callbacks Discussion

I disagree with Vlad. Keep up the good work, I will happily subscribe.

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

© 2021 GoRails, LLC. All rights reserved.