-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add all generated attributes to attr_accessible whitelist. #1578.
- Loading branch information
Showing
2 changed files
with
20 additions
and
14 deletions.
There are no files selected for viewing
26 changes: 15 additions & 11 deletions
26
core/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
module Refinery | ||
module <%= namespacing %> | ||
class <%= class_name %> < Refinery::Core::BaseModel | ||
<% if table_name == namespacing.underscore.pluralize -%>self.table_name = 'refinery_<%= plural_name %>'<% end -%> | ||
<% if localized? %> | ||
translates <%= localized_attributes.map{|a| ":#{a.name}"}.join(', ') %><% 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 | ||
<% if table_name == namespacing.underscore.pluralize -%> | ||
self.table_name = 'refinery_<%= plural_name %>' | ||
<% end %> | ||
attr_accessible <%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>, :position | ||
<% if localized? -%> | ||
translates <%= localized_attributes.map{|a| ":#{a.name}"}.join(', ') %> | ||
<% end -%> | ||
<% if (string_attributes = attributes.select{ |a| a.type.to_s =~ /string|text/ }.uniq).any? -%> | ||
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 %> | ||
<% 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 | ||
"Override def title in vendor/extensions/<%= namespacing.underscore %>/app/models/refinery/<%= namespacing.underscore %>/<%= singular_name %>.rb" | ||
end | ||
<% end -%> | ||
<% attributes.select{|a| a.type.to_s == 'image'}.uniq.each do |a| -%> | ||
<% end -%> | ||
<% attributes.select{|a| a.type.to_s == 'image'}.uniq.each do |a| -%> | ||
belongs_to :<%= a.name.gsub("_id", "") -%>, :class_name => '::Refinery::Image' | ||
<% end -%> | ||
<% attributes.select{|a| a.type.to_s == 'resource'}.uniq.each do |a| -%> | ||
<% end -%> | ||
<% 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 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters