Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick for #1613 #1669

Merged
merged 1 commit into from
May 17, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class Translation
<% end -%>
<% if (string_attributes = attributes.select{ |a| a.type.to_s =~ /string|text/ }.uniq).any? -%>

attr_accessible <%= string_attributes.first.name.to_sym.inspect %>, :position
attr_accessible <%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>, :position

acts_as_indexed :fields => <%= string_attributes.map{|s| s.name.to_sym}.inspect %>

validates <%= string_attributes.first.name.to_sym.inspect %>, :presence => true, :uniqueness => true
<% else -%>

# def title was created automatically because you didn't specify a string field
# when you ran the refinery:engine generator. <3 <3 Refinery CMS.
def title
Expand All @@ -34,6 +33,7 @@ def title
<% attributes.select{|a| a.type.to_s == 'resource'}.uniq.each do |a| -%>

belongs_to :<%= a.name.gsub("_id", "") %>, :class_name => '::Refinery::Resource'

<% end -%>
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ module <%= class_name.pluralize %>
class <%= class_name %> < Refinery::Core::BaseModel
<% if table_name == namespacing.underscore.pluralize -%>
self.table_name = 'refinery_<%= plural_name %>'
<% end -%>
<% if (text_or_string_fields = attributes.map{ |a| a.name if a.type.to_s =~ /string|text/ }.compact.uniq).any? %>
<% end %>
attr_accessible <%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>, :position

<% if (text_or_string_fields = attributes.map{ |a| a.name if a.type.to_s =~ /string|text/ }.compact.uniq).any? -%>
acts_as_indexed :fields => [:<%= text_or_string_fields.join(", :") %>]
<% end -%>
<% if (text_fields = attributes.map {|a| a.name if a.type.to_s == 'text'}.compact.uniq).any? && text_fields.detect{|a| a.to_s == 'message'}.nil? %>
<% if (text_fields = attributes.map {|a| a.name if a.type.to_s == 'text'}.compact.uniq).any? && text_fields.detect{|a| a.to_s == 'message'}.nil? -%>
alias_attribute :message, :<%= text_fields.first %>
<% elsif text_fields.empty? %>
# def message was created automatically because you didn't specify a text field
Expand Down