Reliqs

a collection

Emonlight is out.

Published on 22/05/2016 at 13:04 under , . Tags ,

0 comments

ActiveAdmin-Globalize3-inputs is a little rails gem related to help i18n handling in active_admin.

There is a little bug in current version 0.0.1 that produce javascript error when the model is nested (i.e. Content::Article), that I patched and sent using the great github's pull request.

Published on 11/04/2013 at 12:35 under . Tags ,

0 comments

After upgrading to 0.6.0 version the method actions is finally available. A little tip in case you have to add more than one link to actions, you have to remember that you are building up a view, and the block you are passing have to produce a string, so, a way to accomplish the task is here:

  index do
    column :name
    ...
    actions do |resource|
      links = ''.html_safe
      links << link_to("Custom 1", custom1_admin_resource_path(resource), class: "member_link edit_link")
      links << link_to("Custom 2", custom2_admin_resource_path(resource), class: "member_link edit_link")
      links
    end
  end                                 

Published on 10/04/2013 at 14:07 under . Tags ,

0 comments

I found this little bug in rails engine active_admin version 0.5.1, customizing actions in index using nested models.

Defining a customized actions for a nested model in index

ActiveAdmin.register Content::Article do
  
  index do
    actions do |a|
      link_to a
    end
  end
end

produce this error

ActionView::Template::Error (undefined method `actions' for

:ActiveAdmin::Views::IndexAsTable): 1: insert_tag renderer_for(:index) app/admin/content_articles.rb:4:in `block (2 levels) in '

This is the related issue https://github.com/gregbell/active_admin/issues/2073

Update problem solved simply upgrading to version 0.6.0, thanks to great support from activeadmin crew.

Published on 08/04/2013 at 06:10 under . Tags ,

0 comments

ActiveModel is a module containing functionality extracted from ActiveRecord but not related to db handling.

Functionalities are grouped in submodules:

  • Validations
  • Conversion
  • ...

here an example taken from referenced article

    class Message  
      include ActiveModel::Validations  
      include ActiveModel::Conversion  
      extend ActiveModel::Naming  
        
      attr_accessor :name, :email, :content  
       
      validates_presence_of :name  
      validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i  
      validates_length_of :content, :maximum => 500  
        
      def initialize(attributes = {})  
        attributes.each do |name, value|  
          send("#{name}=", value)  
        end  
      end  
        
      def persisted?  
        false  
      end  
    end  

References

Published on 03/04/2013 at 17:19 under . Tags ,

0 comments

A simple way to define a common behaviour for ActiveRecord models, avoiding to fall into model inheritance.

The method acts_as_* have to be called by models.

 
module CommonBehaviour   
  def acts_as_common     
    belongs_to :content       
    cattr_accessor :shared   
  end 
end 
ActiveRecord::Base.extend CommonBehaviour 

... 

require 'common_behaviour' 
class Article < ActiveRecord::Base   
  acts_as_common   
  attr_accessible :abstract, :body, :title 
end 

References

Published on 03/04/2013 at 09:28 under . Tags ,

0 comments

Powered by Typo – Thème Frédéric de Villamil | Photo Glenn