Displaying 5 results from an estimated 5 matches for "activerecordbase".
2012 Jun 21
1
ActiveModel::Serializers::JSON support arbitrary keys
...son why AM:S doesn''t support arbitrary keys to serialization?
I can see a lot of uses cases where arbitrary keys could come handy. Right
now, if one tries to do it, AM:S checks if the keys match a method of the
model and raises exception if it can''t find any.
class Client < ActiveRecordBase
attr_accessible :name, :address, as: :creator
include ActiveModel::Serializers::JSON
def attributes
{label: name, value: id}
end
While I can easily create a method for all the keys I want to create, take
the example above, where a jquery plugin requires a data structure of
"value: id,...
2012 Jul 25
0
Rails3-default_scope throws exception: undefined method abstract_class? for Object:Class
...false when user clicks on destroy link.
2.
Merge the ''available=true'' condition to all ActiveRecord''s queries while fetching the records.
With reference Rails extending ActiveRecord::Base<http://stackoverflow.com/questions/2328984/rails-extending-activerecordbase>,
I decided to use monkey patch to do above. Created monkey patch file in
config/initializer/active_record_patch.rb:
class ActiveRecord::Base
def inactive
update_attribute(:available, false)
end
default_scope :available => true
end
Getting following error when add the defa...
2007 Jul 18
16
Edge Rails namespaced routing
Hi,
I was wondering if anyone came across a similar scenario when working
with namespaced routes with edge rails.
Consider an application with controllers customers and products that
also have other resources.
map.resources :customers do |customer|
customer.resources :notes
customer.resources :tags
end
map.resources :products do |product|
customer.resources :notes
customer.resources
2010 Sep 17
6
Rails base model
I''m very new to Ruby and to Rails. I''m coming from PHP and CakePHP.
I would like to create a base model from which all other models will
inherit from.
I have done this:
class AppModel < ActiveRecord::Base
end
and
class Post < AppModel
end
I''m getting the following error:
Table ''blog_development.app_models'' doesn''t exist
My
2010 Oct 06
16
Dealing with an EAV database
I''ve inherited an EAV database and there''s really no option to remodel
it. Data is stored as key_name, key_value pairs
Trying to return a meaningful, unified recordset is far too complex to
be efficient.
I''ve decided to make use of the MySQL GROUP_CONCAT, and CONCAT_WS
functions to return a fast query result, with the consolidated fields
as one string.
The final data is