The page_parts extension works perfectly fine in general but when trying to
add a file page_part in a small custom extension I get an error.   Is there
anything following that I might have screwed up?

First, the setup.

Radiant 0.9.1. Latest page_parts extension.  paperclip is installed.  gem
put in env.rb.

migration created and added for "photo"

class AddPaperclipFields < ActiveRecord::Migration
  def self.up
    add_column :page_parts, :photo_file_name, :string
    add_column :page_parts, :photo_content_type, :string
    add_column :page_parts, :photo_file_size, :integer
  end

  def self.down
    remove_column :page_parts, :photo_file_name
    remove_column :page_parts, :photo_content_type
    remove_column :page_parts, :photo_file_size
  end
end


extension...\app\models\file_page_part.rb

class FilePagePart < PagePart
  has_attached_file :photo
  attr_accessor :delete

  def before_save
    self.photo.clear if delete
  end

  def render_content
    self.photo.url
  end
end


extension...\app\views\admin\page_parts\_file_page_part.html.haml

- if page_part.photo.file?
.row
== Delete #{page_part.photo.original_filename}?
= check_box_tag "page[parts_attributes][#{page_part_counter}][delete]",
:value => true
.row
= file_field_tag "page[parts_attributes][#{page_part_counter}][photo]",
:value => page_part.photo.original_filename


And when I add the file page part to a new page

*NoMethodError in Admin/page partsController#create*

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?

RAILS_ROOT: /private/var/www/vhosts/mancc.org/docs
 Application 
Trace<http://localhost:3000/admin/pages/15/children/new?factory=ArtistProfilePageFactory#>|
Framework
Trace<http://localhost:3000/admin/pages/15/children/new?factory=ArtistProfilePageFactory#>|
Full
Trace<http://localhost:3000/admin/pages/15/children/new?factory=ArtistProfilePageFactory#>

/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:142:in
`create_time_zone_conversion_attribute?'
/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:75:in
`define_attribute_methods'
/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in
`each'
/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in
`define_attribute_methods'
/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:246:in
`method_missing'
/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/app/models/page_part.rb:18:in
`after_initialize'
/Library/Ruby/Gems/1.8/gems/radiant-0.9.1/app/controllers/admin/resource_controller.rb:144:in
`load_model'

Reply via email to