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
# lib/formtastic.rb | |
def find_collection_for_column(column, options) | |
collection = find_raw_collection_for_column(column, options) | |
... | |
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
# lib/formtastic.rb | |
def find_raw_collection_for_column(column, options) #:nodoc: | |
collection = if options[:collection] | |
options.delete(:collection) | |
elsif reflection = self.reflection_for(column) | |
options[:find_options] ||= {} | |
if conditions = reflection.options[:conditions] | |
options[:find_options][:conditions] = reflection.klass.merge_conditions(conditions, options[:find_options][:conditions]) | |
end | |
reflection.klass.find(:all, options[:find_options]) |
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
def select_input(method, options) | |
... | |
collection = find_collection_for_column(method, options) | |
self.select(input_name, collection, strip_formtastic_options(options), html_options) | |
... | |
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
Player.find(:all) # retrieves all the players |
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
reflection = self.reflection_for(column) # returns a Reflection object. |
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
reflection.klass # retrieves the Player class in our case |
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
reflection.klass.find(:all, options[:find_options]) # equivalent to Player.find(:all, options[:find_options]) |
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
# lib/formtastic.rb | |
def localized_string(key, value, type, options = {}) #:nodoc: | |
key = value if value.is_a?(::Symbol) | |
if value.is_a?(::String) | |
value | |
else | |
use_i18n = value.nil? ? @@i18n_lookups_by_default : (value != false) | |
if use_i18n | |
model_name, nested_model_name = normalize_model_name(self.model_name.underscore) | |
action_name = template.params[:action].to_s rescue '' |
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
def localized_string(key, value, type, options = {}) |
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
# lib/formtastic/i18n.rb | |
SCOPES = [ | |
'{{model}}.{{nested_model}}.{{action}}.{{attribute}}', | |
'{{model}}.{{action}}.{{attribute}}', | |
'{{model}}.{{nested_model}}.{{attribute}}', | |
'{{model}}.{{attribute}}', | |
'{{nested_model}}.{{attribute}}', | |
'{{attribute}}' | |
] |