On Jan 29, 10:46 am, "David Sedeño" <
frim...@gmail.com> wrote:
> Well, the password is actsaspassword (is in one page on the wiki). You can
> also read the wiki in read only mode. The link in read only is:
>
>
http://wiki.activescaffold.com/wiki/published/ActiveScaffold+with+Att...
Thanks for the link, David. I did manage to find that link myself
last night after some Googling, and I tried using attachment-fu with
Active Scaffold as you described. Many thanks for the writeup.
I set up two models just like in the wiki page and all I get is
mysterious nil object errors from deep within attachment-fu. Probably
something that I'm doing wrong but the errors don't help much to
figure out my problem.
My setup mirrors the wiki page, I'm using "Event" instead of "Person"
and "Flyer" instead of "Image", but other than that it's the same
exact setup:
in events_controller.rb:
class EventsController < ApplicationController
active_scaffold :events do |config|
config.columns.add :uploaded_data
config.create.multipart = true
config.create.columns = [:uploaded_data, :name]
config.nested.add_link("Flyers", [:flyers])
end
end
in flyers_controller.rb:
class FlyersController < ApplicationController
active_scaffold :flyers do |config|
config.columns.add :uploaded_data
config.columns.exclude :uploaded_data
config.create.multipart = true
config.create.columns = [:uploaded_data, :name]
config.list.columns = [:filename, :image]
end
end
in events_helper.rb:
module EventsHelper
def uploaded_data_form_column(record, input_name)
file_field_tag input_name
end
end
in flyers_helper.rb:
module FlyersHelper
def image_column(record)
image_tag record.public_filename(:thumb)
end
end
in event.rb:
class Event < ActiveRecord::Base
has_many :flyers
def uploaded_data
nil
end
def uploaded_data=(data)
self.flyers<< Flyer.new(:uploaded_data => data)
end
end
in flyer.rb:
class Flyer < ActiveRecord::Base
belongs_to :event
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 5500.kilobytes,
:resize_to => '708x708>',
:thumbnails => { :thumb => '190x190>' },
:path_prefix => 'public/uploads'
validates_as_attachment
end
The mysterious error that I see when I press the "Flyers" button in
the "Events" controller:
ActionView::TemplateError (You have a nil object when you didn't
expect it!
The error occurred while evaluating nil.gsub) on line #10 of vendor/
plugins/active_scaffold/frontends/default/views/_list_record.rhtml:
7:
8: <tr class="record <%= tr_class %>" id="<%= element_row_id(:action
=> :list, :id =>
record.id) %>">
9: <% active_scaffold_config.list.columns.each do |column| %>
10: <% column_value = get_column_value(record, column) -%>
11:
12: <td class="<%= column_class(column, column_value) %>" >
13: <%= render_list_column(column_value, column, record) %>
/Users/rap/projects/venuedriver/vendor/plugins/attachment_fu/lib/
technoweenie/attachment_fu.rb:201:in `thumbnail_name_for'
/Users/rap/projects/venuedriver/vendor/plugins/attachment_fu/lib/
technoweenie/attachment_fu/backends/file_system_backend.rb:21:in
`full_filename'
/Users/rap/projects/venuedriver/vendor/plugins/attachment_fu/lib/
technoweenie/attachment_fu/backends/file_system_backend.rb:43:in
`public_filename'
/Users/rap/projects/venuedriver/app/helpers/flyers_helper.rb:3:in
`image_column'
/Users/rap/projects/venuedriver/vendor/plugins/active_scaffold/lib/
helpers/list_column_helpers.rb:11:in `send'
/Users/rap/projects/venuedriver/vendor/plugins/active_scaffold/lib/
helpers/list_column_helpers.rb:11:in `get_column_value'
That error doesn't seem to have anything at all to do with any code
that I wrote, so it's a pretty steep challenge to figure out WTF is
wrong. I don't even know where to start. If anybody has any
suggestions then I would greatly appreciate it.