Problem I have two Models in my Rails 6 / PostgreSQL application which have a many to many relation; Car […]
Tag: active-record
User model with validation, delegates, and carrierwave upload mounter
Problem I’ve refactored this model about 50 times according to codeclimate, trying to get the code smell down. With all […]
Filtering users by criteria in Ruby on Rails
Problem I am a fairly new (RubyonRails) developer. I desire to improve my coding skills so I used climate to […]
Display related records, if they exist, in Rails view
Problem Is this much logic in view is justified to check for the presence of record? # device model class […]
Rails User Model
Problem This is an app that I started on a while back to get digging into Rails. It’s grown and […]
Finding users who liked a post
Problem I have a method liked_by and it doesn’t seem like appropriate as per Ruby style. I need to do […]
ActiveRecord count
Problem Here I retrieve a collection of causes from the database. Along with the information from each cause, I want […]
Counting number of messages for a mailbox over several periods
Problem The idea is to return a number of messages received today, this week, this month. def index @mailboxes = […]
Getting last 5 leave requests for a user – where does the code live [closed]
Problem Closed. This question is off-topic. It is not currently accepting answers. Questions must involve real code that you own […]
Simpler method to find users in child categories
Problem I am using the ancestry gem to organize my post categories tree. I have 8 parent categories, and they […]