January 12, 2017 by Daniel P. Clark

Re: What is the splat operator doing here?

I’ve received an email from a fellow software developer inquiring about a bit of code where I use Ruby’s splat operator in two different ways.  In my Ruby gem cards_lib I wrote a “macro” to take a list of strings and generate card instances from them.  You don’t really hear of macros in the Ruby community…

Continue Reading »

March 22, 2016 by Daniel P. Clark

Rails: Has One Through Polymorphic Relation

As I’ve described in my blog post “Rails Polymorphic Associations” I’ve stated that polymorphic relations in Rails are best for scenarios where a model may “belong to” one of many other kinds of model.  So a Comment model with the polymorphic commentable relationship can belong to any other record in your Rails app.  This is…

Continue Reading »

January 5, 2015 by Daniel P. Clark

Dealing with Rails 4 forms and params

In the learning stage of Rails developments one will come across different scenarios of handling parameters from Rails forms that are submitted.  Also since Rails 4 introduced Strong Parameters there are some additional things to keep in mind. Form Params 101 Parameters: { “utf8″=>”✓”, “authenticity_token”=>”nqLr/ZukyXt5/sFNU9FGciBbSOSJ2MkE7Roo5WwfVEo=”, “profile”=>{ “first_name”=>”Daniel”, “last_name”=>”Clark”, “socials_attributes”=>{ “0”=>{ “kind”=>”twitter”, “username”=>”@6ftdan” } } },…

Continue Reading »