app/models/constructor_pages/field.rb in constructor-pages-0.5.8 vs app/models/constructor_pages/field.rb in constructor-pages-0.6.0
- old
+ new
@@ -3,12 +3,10 @@
module ConstructorPages
# Field model. Fields allows to add custom fields for template.
#
# Each field has type of value such as float, integer, string...
class Field < ActiveRecord::Base
- attr_accessible :name, :code_name, :type_value, :template_id, :template
-
# Adding code_name_uniqueness method
include CodeNameUniq
# Array of available field types
TYPES = %w{string integer float boolean text date html image}
@@ -36,10 +34,10 @@
# Return constant of model type_value
def type_class; "constructor_pages/types/#{type_value}_type".classify.constantize end
# Return object of type_value by page
- def find_type_object(page); type_class.find_by_field_id_and_page_id(id, page.id) end
+ def find_type_object(page); type_class.where(field_id: id, page_id: page.id).first end
# Create object of type_value by page
def create_type_object(page); type_class.create(field_id: id, page_id: page.id) end
# Remove all type_fields values for specified page
\ No newline at end of file