Update : I've narrowed it down to the virtual attribute of updated
data is not firing updated_data= in the HostedSite model.  I added
another virtual column, a text field "abc" to this model and put in a
debugger, and it isn't firing either.

Russell

On Apr 22, 11:17 am, Russell <[email protected]> wrote:
> I've read the docs on how to use attachment_fu with activescaffold,
> and can't seem to get it working.  Specifically, the parent object
> (and other parent objects) scaffolding works just fine, but I can't
> get the attachment object to store or even to show as a nested link.
>
> The model is : HostedSite has one or more LogoAttachement.  Here are
> the files:
>
> class HostedSite < ActiveRecord::Base
>   has_many :logo_attachments
>
>   def uploaded_data
>     nil
>   end
>
>   def uploaded_data=(data)
>     self.logo_attachments << LogoAttachment.new(:uploaded_data =>
> data)
>   end
> end
>
> class Admin::HostedSitesController < Admin::AdminController
>   active_scaffold :hosted_site do |config|
>     config.columns =
> [:title, :domain, :theme, :uploaded_data, :language, :sbr_sportsbook, 
> :parent_site, :relative_directory_name ]
>     list.columns =
> [:title, :domain, :sbr_sportsbook, :theme, :parent_site, 
> :relative_directory_name, :language]
>     config.columns[:sbr_sportsbook].form_ui = :select
>     config.columns[:parent_site].form_ui = :select
>     config.columns[:css_files].options[:rows]=3
>     config.columns[:javascript_files].options[:rows]=3
>     config.create.multipart=true
>     config.nested.add_link("Logos", [:logo_attachments])
>   end
> end
>
> module HostedSiteHelper
>   def uploaded_data_form_column(record, input_name)
>     file_field_tag input_name
>   end
> end
>
> class LogoAttachment < ActiveRecord::Base
>   has_attachment :content_type => :image,
>     :storage => :file_system,
>     :resize_to => '290x96>',
>     :processor => "Rmagick",
>     :thumbnails => { :small => '73x24>' },
>     :path_prefix => 'public/uploads/logo_attachments'
>
>   validates_as_attachment
>   belongs_to :hosted_site
> end
>
> class Admin::LogoAttachmentsController < Admin::AdminController
>
>   active_scaffold :logo_attachment do |config|
>     config.columns.add :uploaded_data
>     config.create.multipart=true
>     config.create.columns = [:uploaded_data]
>     config.list.columns = [:filename, :image]
>   end
> end
>
> module LogoAttachmentHelper
>   def image_column(record)
>     image_tag record.public_filename(:thumb)
>   end
>   def uploaded_data_form_column(record, input_name)
>     file_field_tag input_name
>   end
> end
>
> I've followed the document on the wiki, I think, down to the T and
> have tried 10-20 permutations (tried has_one, tried without Admin::
> namespace, ...).  I can create the attachment in a vanilla controller,
> so it appears fine.    When I try to list the "Logos" for a
> HostedSite, I receive:
>
> Processing Admin::HostedSitesController#nested (for 127.0.0.1 at
> 2010-04-22 11:16:35) [GET]
>   Parameters: {"adapter"=>"_list_inline_adapter", "id"=>"1",
> "associations"=>"logo_attachments"}
>   HostedSite Load (0.2ms)   SELECT * FROM `hosted_sites` WHERE
> (`hosted_sites`.`domain` = 'www.bodog.local') LIMIT 1
>   HostedSite Load (0.1ms)   SELECT * FROM `hosted_sites` WHERE
> (`hosted_sites`.`id` = 1)
>   LogoAttachment Columns (1.2ms)   SHOW FIELDS FROM `logo_attachments`
>
> ActionView::TemplateError (undefined method `render_component' for
> #<ActionView::Base:0x103449658>) on line #31 of vendor/plugins/
> active_scaffold/frontends/default/views/_nested.html.erb:
> 28:           :constraints => @constraints,
> 29:           :conditions => association.options[:conditions],
> 30:           :label => h(@label),
> 31:           :params => {:nested => true, :parent_column =>
> column_name, :parent_model => association.active_record.name}
> 32:         )
> 33:       end
> 34:     end
>
>     vendor/plugins/active_scaffold/frontends/default/views/
> _nested.html.erb:31
>     vendor/plugins/active_scaffold/frontends/default/views/
> _nested.html.erb:11:in `each'
>     vendor/plugins/active_scaffold/frontends/default/views/
> _nested.html.erb:11
>     haml (2.2.3) lib/haml/helpers/action_view_mods.rb:13:in
> `render_without_active_scaffold'
>     haml (2.2.3) rails/./lib/sass/plugin/rails.rb:19:in `process'
>
> Rendered rescues/_trace (54.4ms)
> Rendered rescues/_request_and_response (0.4ms)
> Rendering rescues/layout (internal_server_error)
>
> Also, if I try to go to the logo listing screen directly and add a
> logo, it fails as well.
>
> Thanks in advance...
>
> Russell
>
> --
> You received this message because you are subscribed to the Google Groups 
> "ActiveScaffold : Ruby on Rails plugin" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/activescaffold?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.

Reply via email to