Module: ActiveScaffold::Helpers::ListColumnHelpers
- Included in:
- ViewHelpers
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb,
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb
Overview
Helpers that assist with the rendering of a List Column
Instance Method Summary collapse
-
#action_link_to_inline_form(column, associated) ⇒ Object
setup the action link to inline form.
- #active_scaffold_column_checkbox(column, record) ⇒ Object
-
#active_scaffold_column_download_link(column, record, label = nil) ⇒ Object
HOWTO <% column = active_scaffold_config.columns %> <% doc = Document.find(:first, :conditions => [“name = ?”, doc_name]) %> <%= active_scaffold_column_download_link(column, doc) %>.
-
#active_scaffold_column_download_link_url_options(column, record) ⇒ Object
AST - active_scaffold_column_download_link_url_options.
- #active_scaffold_column_download_link_with_filename(column, record) ⇒ Object
- #active_scaffold_column_percentage(column, record) ⇒ Object
- #active_scaffold_column_phone_number(column, record) ⇒ Object
- #active_scaffold_column_ssn(column, record) ⇒ Object
-
#active_scaffold_column_text(column, record) ⇒ Object
Overrides.
- #active_scaffold_column_thumbnail(column, record) ⇒ Object
- #active_scaffold_column_usa_money(column, record) ⇒ Object
- #active_scaffold_column_usa_zip_code(column, record) ⇒ Object
- #active_scaffold_in_place_editor(field_id, options = {}) ⇒ Object
-
#active_scaffold_inplace_edit(record, column, options = {}) ⇒ Object
AST - options param.
- #cache_association(value, column) ⇒ Object
-
#clean_column_value(v) ⇒ Object
There are two basic ways to clean a column’s value: h() and sanitize().
- #column_override(column) ⇒ Object
- #column_override?(column) ⇒ Boolean
- #format_association_value(value, column, size) ⇒ Object
-
#format_column_value(record, column) ⇒ Object
Formatting.
- #format_inplace_edit_column(record, column) ⇒ Object
- #format_number_value(value, options = {}) ⇒ Object
- #format_value(column_value, options = {}) ⇒ Object
- #get_column_value(record, column) ⇒ Object
-
#inplace_edit?(record, column) ⇒ Boolean
= Inline Edit = ==========.
- #inplace_edit_cloning?(column) ⇒ Boolean
- #inplace_edit_control(column) ⇒ Object
- #inplace_edit_control_css_class ⇒ Object
-
#nested_label(association) ⇒ Object
AST Begin.
-
#override_column_ui(list_ui) ⇒ Object
the naming convention for overriding column types with helpers.
- #override_column_ui?(list_ui) ⇒ Boolean
-
#render_list_column(text, column, record) ⇒ Object
TODO: move empty_field_text and logic in here? TODO: move active_scaffold_inplace_edit in here? TODO: we need to distinguish between the automatic links we create and the ones that the dev specified.
Instance Method Details
#action_link_to_inline_form(column, associated) ⇒ Object
setup the action link to inline form
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 85 def action_link_to_inline_form(column, associated) link = column.link.clone if column_empty?(associated) # if association is empty, we only can link to create form if column.actions_for_association_links.include?(:new) link.action = 'new' link.crud_type = :create end elsif column.actions_for_association_links.include?(:edit) link.action = 'edit' link.crud_type = :update elsif column.actions_for_association_links.include?(:show) link.action = 'show' link.crud_type = :read end link end |
#active_scaffold_column_checkbox(column, record) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 120 def active_scaffold_column_checkbox(column, record) column_value = record.send(column.name) checked = column_value.class.to_s.include?('Class') ? column_value : column_value == 1 if column.inplace_edit and record.(:action => :update, :column => column.name) = {:id => record.id.to_s, :action => 'update_column', :name => column.name.to_s} = {:tag => "span", :id => element_cell_id(), :class => "in_place_editor_field"} script = remote_function(:method => 'POST', :url => {:controller => params_for[:controller], :action => "update_column", :column => column.name, :id => record.id.to_s, :value => !column_value, :eid => params[:eid]}) content_tag(:span, check_box_tag([:id], 1, checked, {:onclick => script}) , ) else check_box_tag(nil, 1, checked, :disabled => true) end end |
#active_scaffold_column_download_link(column, record, label = nil) ⇒ Object
HOWTO <% column = active_scaffold_config.columns %> <% doc = Document.find(:first, :conditions => [“name = ?”, doc_name]) %> <%= active_scaffold_column_download_link(column, doc) %>
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb', line 14 def active_scaffold_column_download_link(column, record, label = nil) return nil if record.send(column.name).nil? label ||= as_(:download) # AST Begin - :secure_download if column.[:secure_download] = (column, record) else = url_for_file_column(record, column.name.to_s) end # AST End link_to( label, , :popup => true) end |
#active_scaffold_column_download_link_url_options(column, record) ⇒ Object
AST - active_scaffold_column_download_link_url_options
28 29 30 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb', line 28 def (column, record) {:controller => active_scaffold_config.secure_download_controller, :action => "show", :id => record.id, :download => url_for_file_column(record, column.name.to_s)}#.encrypt!(:symmetric, :key => active_scaffold_config.secure_download_key)} end |
#active_scaffold_column_download_link_with_filename(column, record) ⇒ Object
5 6 7 8 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb', line 5 def active_scaffold_column_download_link_with_filename(column, record) return nil if record.send(column.name).nil? active_scaffold_column_download_link(column, record, File.basename(record.send(column.name))) end |
#active_scaffold_column_percentage(column, record) ⇒ Object
357 358 359 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 357 def active_scaffold_column_percentage(column, record) number_to_percentage(record.send(column.name).to_s, :precision => 1) end |
#active_scaffold_column_phone_number(column, record) ⇒ Object
379 380 381 382 383 384 385 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 379 def active_scaffold_column_phone_number(column, record) if record.respond_to?("#{column.name}_for_human") record.send("#{column.name}_for_human") else usa_number_to_phone(record.send(column.name).to_s) end end |
#active_scaffold_column_ssn(column, record) ⇒ Object
361 362 363 364 365 366 367 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 361 def active_scaffold_column_ssn(column, record) if record.respond_to?("#{column.name}_for_human") record.send("#{column.name}_for_human") else usa_number_to_ssn(record.send(column.name).to_s) end end |
#active_scaffold_column_text(column, record) ⇒ Object
Overrides
116 117 118 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 116 def active_scaffold_column_text(column, record) truncate(clean_column_value(record.send(column.name)), :length => column.[:truncate] || 50) end |
#active_scaffold_column_thumbnail(column, record) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb', line 32 def active_scaffold_column_thumbnail(column, record) return nil if record.send(column.name).nil? link_to( image_tag(url_for_file_column(record, column.name.to_s, "thumb"), :border => 0), url_for_file_column(record, column.name.to_s), :popup => true) end |
#active_scaffold_column_usa_money(column, record) ⇒ Object
369 370 371 372 373 374 375 376 377 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 369 def active_scaffold_column_usa_money(column, record) value = record.send(column.name) formatted_value = number_to_currency(value.abs.to_s) if value if value and value < 0.0 "(#{formatted_value})" else formatted_value end end |
#active_scaffold_column_usa_zip_code(column, record) ⇒ Object
387 388 389 390 391 392 393 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 387 def active_scaffold_column_usa_zip_code(column, record) if record.respond_to?("#{column.name}_for_human") record.send("#{column.name}_for_human") else usa_number_to_zip(record.send(column.name).to_s) end end |
#active_scaffold_in_place_editor(field_id, options = {}) ⇒ Object
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 306 def active_scaffold_in_place_editor(field_id, = {}) function = "new ActiveScaffold.InPlaceEditor(" function << "'#{field_id}', " function << "'#{url_for([:url])}'" = {} if protect_against_forgery? [:with] ||= "Form.serialize(form)" [:with] += " + '&authenticity_token=' + encodeURIComponent('#{form_authenticity_token}')" end ['cancelText'] = %('#{[:cancel_text]}') if [:cancel_text] ['okText'] = %('#{[:save_text]}') if [:save_text] ['okControl'] = %('#{[:save_control_type]}') if [:save_control_type] ['cancelControl'] = %('#{[:cancel_control_type]}') if [:cancel_control_type] ['loadingText'] = %('#{[:loading_text]}') if [:loading_text] ['savingText'] = %('#{[:saving_text]}') if [:saving_text] ['rows'] = [:rows] if [:rows] ['cols'] = [:cols] if [:cols] ['size'] = [:size] if [:size] ['externalControl'] = "'#{[:external_control]}'" if [:external_control] ['externalControlOnly'] = "true" if [:external_control_only] ['submitOnBlur'] = "'#{[:submit_on_blur]}'" if [:submit_on_blur] ['loadTextURL'] = "'#{url_for([:load_text_url])}'" if [:load_text_url] ['ajaxOptions'] = [:ajax_options] if [:ajax_options] ['htmlResponse'] = ![:script] if [:script] ['callback'] = "function(form) { return #{[:with]} }" if [:with] ['clickToEditText'] = %('#{[:click_to_edit_text]}') if [:click_to_edit_text] ['textBetweenControls'] = %('#{[:text_between_controls]}') if [:text_between_controls] ['highlightcolor'] = %('#{[:highlight_color]}') if [:highlight_color] ['highlightendcolor'] = %('#{[:highlight_end_color]}') if [:highlight_end_color] ['onFailure'] = "function(element, transport) { #{[:failure]} }" if [:failure] ['onComplete'] = "function(transport, element) { #{[:complete]} }" if [:complete] ['onEnterEditMode'] = "function(element) { #{[:enter_editing]} }" if [:enter_editing] ['onLeaveEditMode'] = "function(element) { #{[:exit_editing]} }" if [:exit_editing] ['onFormCustomization'] = "function(element, form) { #{[:form_customization]} }" if [:form_customization] ['inplacePatternSelector'] = %('#{[:inplace_pattern_selector]}') if [:inplace_pattern_selector] ['nodeIdSuffix'] = %('#{[:node_id_suffix]}') if [:node_id_suffix] function << (', ' + ()) unless .empty? function << ')' javascript_tag(function) end |
#active_scaffold_inplace_edit(record, column, options = {}) ⇒ Object
AST - options param
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 257 def active_scaffold_inplace_edit(record, column, = {}) formatted_column = [:formatted_column] || format_inplace_edit_column(record, column) # AST End = {:id => record.id.to_s, :action => 'update_column', :name => column.name.to_s} = {:tag => "span", :id => element_cell_id(), :class => "in_place_editor_field"} = { :url => {:controller => params_for[:controller], :action => "update_column", :column => column.name, :id => record.id.to_s}, :with => params[:eid] ? "Form.serialize(form) + '&eid=#{params[:eid]}'" : nil, :click_to_edit_text => as_(:click_to_edit), :cancel_text => as_(:cancel), :loading_text => as_(:loading), :save_text => as_(:update), :saving_text => as_(:saving), :ajax_options => "{method: 'post'}", :script => true } if inplace_edit_cloning?(column) .merge!( :inplace_pattern_selector => "##{active_scaffold_column_header_id(column)} .#{inplace_edit_control_css_class}", :node_id_suffix => record.id.to_s, :form_customization => 'element.clonePatternField();' ) elsif column.inplace_edit == :ajax url = url_for(:action => 'render_field', :id => record.id, :column => column.name, :update_column => column.name, :in_place_editing => true, :escape => false) [:form_customization] = "element.setFieldFromAjax('#{escape_javascript(url)}');" elsif column.column.try(:type) == :text [:rows] = column.[:rows] || 5 end .merge!(column.) content_tag(:span, formatted_column, ) + active_scaffold_in_place_editor([:id], ) end |
#cache_association(value, column) ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 223 def cache_association(value, column) # we are not using eager loading, cache firsts records in order not to query the database in a future unless value.loaded? # load at least one record, is needed for column_empty? and checking permissions if column.associated_limit.nil? Rails.logger.warn "ActiveScaffold: Enable eager loading for #{column.name} association to reduce SQL queries" else value.target = value.find(:all, :limit => column.associated_limit + 1, :select => column.select_columns) end end end |
#clean_column_value(v) ⇒ Object
There are two basic ways to clean a column’s value: h() and sanitize(). The latter is useful when the column contains valid html data, and you want to just disable any scripting. People can always use field overrides to clean data one way or the other, but having this override lets people decide which way it should happen by default.
Why is it not a configuration option? Because it seems like a somewhat rare request. But it could eventually be an option in config.list (and config.show, I guess).
109 110 111 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 109 def clean_column_value(v) h(v) end |
#column_override(column) ⇒ Object
133 134 135 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 133 def column_override(column) "#{column.name.to_s.gsub('?', '')}_column" # parse out any question marks (see issue 227) end |
#column_override?(column) ⇒ Boolean
137 138 139 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 137 def column_override?(column) respond_to?(column_override(column)) end |
#format_association_value(value, column, size) ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 188 def format_association_value(value, column, size) case column.association.macro when :has_one, :belongs_to format_value(value.to_label) when :has_many, :has_and_belongs_to_many if column.associated_limit.nil? firsts = value.collect { |v| v.to_label } else firsts = value.first(column.associated_limit) firsts.collect! { |v| v.to_label } firsts[column.associated_limit] = '…' if value.size > column.associated_limit end if column.associated_limit == 0 size if column.associated_number? else joined_associated = format_value(firsts.join(', ')) joined_associated << " (#{size})" if column.associated_number? and column.associated_limit and value.size > column.associated_limit joined_associated end end end |
#format_column_value(record, column) ⇒ Object
Formatting
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 154 def format_column_value(record, column) value = record.send(column.name) if value && column.association # cache association size before calling column_empty? # AST - Had problems with has_many through when the relationship was empty - AR is creating WHERE ((`trade_days`.id = )). Tried value.empty? but that caused the same problem so we are using (value.length > 0) associated_size = value.size if column.plural_association? and (value.length > 0) and column.associated_number? # get count before cache association cache_association(value, column) end if column.association.nil? or column_empty?(value) if value.is_a? Numeric format_number_value(value, column.) else format_value(value, column.) end else format_association_value(value, column, associated_size) end end |
#format_inplace_edit_column(record, column) ⇒ Object
247 248 249 250 251 252 253 254 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 247 def format_inplace_edit_column(record,column) value = record.send(column.name) if column.list_ui == :checkbox active_scaffold_column_checkbox(column, record) else format_column_value(record, column) end end |
#format_number_value(value, options = {}) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 172 def format_number_value(value, = {}) value = case [:format] when :size number_to_human_size(value, [:i18n_options] || {}) when :percentage number_to_percentage(value, [:i18n_options] || {}) when :currency number_to_currency(value, [:i18n_options] || {}) when :i18n_number send("number_with_#{value.is_a?(Integer) ? 'delimiter' : 'precision'}", value, [:i18n_options] || {}) else value end clean_column_value(value) end |
#format_value(column_value, options = {}) ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 210 def format_value(column_value, = {}) value = if column_empty?(column_value) active_scaffold_config.list.empty_field_text elsif column_value.is_a?(Time) || column_value.is_a?(Date) l(column_value, :format => [:format] || :default) elsif [FalseClass, TrueClass].include?(column_value.class) as_(column_value.to_s.to_sym) else column_value.to_s end clean_column_value(value) end |
#get_column_value(record, column) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 6 def get_column_value(record, column) begin # check for an override helper value = if column_override? column # we only pass the record as the argument. we previously also passed the formatted_value, # but mike perham pointed out that prohibited the usage of overrides to improve on the # performance of our default formatting. see issue #138. send(column_override(column), record, column) # second, check if the dev has specified a valid list_ui for this column elsif column.list_ui and override_column_ui?(column.list_ui) send(override_column_ui(column.list_ui), column, record) elsif inplace_edit?(record, column) active_scaffold_inplace_edit(record, column) elsif column.column and override_column_ui?(column.column.type) send(override_column_ui(column.column.type), column, record) else format_column_value(record, column) end value = ' ' if value.nil? or (value.respond_to?(:empty?) and value.empty?) # fix for IE 6 return value rescue Exception => e logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}" raise e end end |
#inplace_edit?(record, column) ⇒ Boolean
Inline Edit =
239 240 241 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 239 def inplace_edit?(record, column) column.inplace_edit and record.(:action => :update, :column => column.name) end |
#inplace_edit_cloning?(column) ⇒ Boolean
243 244 245 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 243 def inplace_edit_cloning?(column) column.inplace_edit != :ajax and (override_form_field?(column) or column.form_ui or (column.column and override_input?(column.column.type))) end |
#inplace_edit_control(column) ⇒ Object
291 292 293 294 295 296 297 298 299 300 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 291 def inplace_edit_control(column) if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column) @record = active_scaffold_config.model.new column = column.clone column. = column..clone column..delete(:update_column) column.form_ui = :select if (column.association && column.form_ui.nil?) content_tag(:div, active_scaffold_input_for(column), {:style => "display:none;", :class => inplace_edit_control_css_class}) end end |
#inplace_edit_control_css_class ⇒ Object
302 303 304 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 302 def inplace_edit_control_css_class "as_inplace_pattern" end |
#nested_label(association) ⇒ Object
AST Begin
353 354 355 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 353 def nested_label(association) as_(:nested_for_model, :nested_model => active_scaffold_config_for(association.klass).label(:count => 2), :parent_model => format_value(@record.to_label)) end |
#override_column_ui(list_ui) ⇒ Object
the naming convention for overriding column types with helpers
146 147 148 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 146 def override_column_ui(list_ui) "active_scaffold_column_#{list_ui}" end |
#override_column_ui?(list_ui) ⇒ Boolean
141 142 143 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 141 def override_column_ui?(list_ui) respond_to?(override_column_ui(list_ui)) end |
#render_list_column(text, column, record) ⇒ Object
TODO: move empty_field_text and logic in here? TODO: move active_scaffold_inplace_edit in here? TODO: we need to distinguish between the automatic links we create and the ones that the dev specified. some logic may not apply if the dev specified the link.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb', line 37 def render_list_column(text, column, record) # AST Begin make_available_method = "#{column.name}_make_available?" return active_scaffold_config.list.empty_field_text if record.respond_to?(make_available_method) and !record.send(make_available_method) # AST End if column.link link = column.link associated = record.send(column.association.name) if column.association = params_for(:action => nil, :id => record.id, :link => text) [:parent_controller] = params[:controller] if link.controller and link.controller.to_s != params[:controller] [:id] = associated.id if associated and link.controller and link.controller.to_s != params[:controller] # setup automatic link if column.autolink? # link to nested scaffold or inline form link = action_link_to_inline_form(column, associated) if link.crud_type.nil? # automatic link to inline form (singular association) return text if link.crud_type.nil? if link.crud_type == :create [:link] = as_(:create_new) [:parent_id] = record.id [:parent_column] = column.association.reverse [:parent_model] = record.class.name # needed for polymorphic associations .delete :id end end # check authorization if column.association = if associated.nil? || (associated.respond_to?(:empty?) && associated.empty?) column.association.klass elsif column.plural_association? associated.first else associated end = .(:action => link.crud_type) = and record.(:action => :update, :column => column.name) if link.crud_type == :create else = record.(:action => link.crud_type) end return "<a class='disabled'>#{text}</a>" unless render_action_link(link, ) else text end end |