Skip to content

Instantly share code, notes, and snippets.

@rsierra
rsierra / 1ST README.md
Last active December 16, 2015 13:49
Multiple params assignment and dates with multiparams

Simple class multiassignment

Module to use similar model multiple params assignment and dates with multiparams (params["date(1i)"], params["date(2i)"], params["date(3i)"]) in a non ActiveModel class.

class Sample
  include ActiveModel::Multiassignment

  attr_accessor :name, :date
 multiparameter_dates :date
@laurynas
laurynas / item.rb
Created November 26, 2010 10:00
SearchLogic problem with left join in order SOLVED!
class Item < ActiveRecord::Base
named_scope :ascend_by_optional_category_title,
:joins => "LEFT JOIN categories AS optional_categories ON optional_categories.id=items.category_id",
:order => "optional_categories.title"
named_scope :descend_by_optional_category_title,
:joins => "LEFT JOIN categories AS optional_categories ON optional_categories.id=items.category_id",
:order => "optional_categories.title DESC"