File_column error

Hi, Sebastian

I downloaded FileColumn plugin and love the concept. But when I
tried the example listed on the plugin web site, I got the following
error:

 NoMethodError in Entry#new

 undefined method `file_column' for Entry:Class

My environement is Red Hat linux 9.0 with mysql 4.1. I installed
file_column under vendor/plugins. If I run “ls”, I get the following
directories:
file_column rails_file_column

I created a directory, " file_column" and copied files under “trunk”
to file_column.

Please see my controller, models and new.rhtml attached.

Could anyone tell me why I got the error? It seems that rails can not
find “file_column” plugin.

Thanks in advance.


-Thomas

entry.rb:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Entry < ActiveRecord::Base
file_column :image
end

entry_controller.rb:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class EntryController < ApplicationController

Get information on a new product and

attempt to create a row in the database.

def create
@entry = Entry.new(@params[:entry])
if @entry.save
flash[‘notice’] = ‘Entry was successfully created.’
redirect_to :action => ‘list’
else
render_action ‘new’
end
end

def list
@entry_pages, @entries = paginate :entry, :per_page => 10
end

Initiate the creation of a new product.

The work is completed in #create.

def new
@entry = Entry.new
end

end

Error:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NoMethodError in Entry#new

undefined method `file_column’ for Entry:Class

RAILS_ROOT: ./script/…/config/…/
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
method_missing' #{RAILS_ROOT}/app/models/entry.rb:4 /home/txue/downloads/rails-code/depot.0114/app/controllers/entry_controller.rb:21:innew’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
method_missing' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:inload’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in
load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:inrequire_or_load’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in
depend_on' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:inrequire_dependency’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in
require_dependency' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:194:inconst_missing’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:inperform_action_without_filters’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
perform_action_without_benchmark' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
measure' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
perform_action' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:insend’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:inprocess’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:inhandle_dispatch’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/local/lib/ruby/1.8/webrick/server.rb:155:instart_thread’
/usr/local/lib/ruby/1.8/webrick/server.rb:144:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:144:instart_thread’
/usr/local/lib/ruby/1.8/webrick/server.rb:94:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:89:ineach’
/usr/local/lib/ruby/1.8/webrick/server.rb:89:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:79:instart’
/usr/local/lib/ruby/1.8/webrick/server.rb:79:in start' /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:indispatch’
script/server:51

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
method_missing' #{RAILS_ROOT}/app/models/entry.rb:4 /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:inload’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:207:in
load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:39:inrequire_or_load’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:22:in
depend_on' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:inrequire_dependency’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:178:in
require_dependency' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:194:inconst_missing’
/home/txue/downloads/rails-code/depot.0114/app/controllers/entry_controller.rb:21:in
new' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:insend’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in
perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:inperform_action_without_benchmark’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inmeasure’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:inperform_action’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:inprocess_without_session_management_support’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
process' /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:indispatch’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
handle_dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:inservice’
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/usr/local/lib/ruby/1.8/webrick/server.rb:155:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:144:instart’
/usr/local/lib/ruby/1.8/webrick/server.rb:144:in start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:94:instart’
/usr/local/lib/ruby/1.8/webrick/server.rb:89:in each' /usr/local/lib/ruby/1.8/webrick/server.rb:89:instart’
/usr/local/lib/ruby/1.8/webrick/server.rb:79:in start' /usr/local/lib/ruby/1.8/webrick/server.rb:79:instart’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch’
script/server:51

This error occured while loading the following files:
entry.rb

Request

Parameters: None

Show session dump


flash: !ruby/hash:ActionController::Flash::FlashHash {}

Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}

On Jan 16, 2006, at 12:34 AM, Tom S. wrote:

My environement is Red Hat linux 9.0 with mysql 4.1. I installed
find “file_column” plugin.
end
redirect_to :action => ‘list’

The work is completed in #create.

def new
@entry = Entry.new
end

end

Error:

Tom,

A couple of things to check, just off hand. First, did you restart
your webserver? Plugins are loaded once, during initialization, and
not for every page load. Second, is there an init.rb file directly
inside the vendor/plugins/file_column/ directory? If so, can you add
some debug output such as "RAILS_DEFAULT_LOGGER.error ‘inside
init.rb’ " and see the output in your log files (this would confirm
that init.rb is being seen by the initializer)? And you’re running
Rails 1.0?

Duane J.
(canadaduane)

Tom S. wrote:

Hi, Sebastian

I downloaded FileColumn plugin and love the concept. But when I
tried the example listed on the plugin web site, I got the following
error:

 NoMethodError in Entry#new

 undefined method `file_column' for Entry:Class

My environement is Red Hat linux 9.0 with mysql 4.1. I installed
file_column under vendor/plugins. If I run “ls”, I get the following
directories:
file_column rails_file_column

I created a directory, " file_column" and copied files under “trunk”
to file_column.

Please see my controller, models and new.rhtml attached.

Does your “entries” database table contain a varchar field called
“image”? That’s a necessary piece of using file_column that isn’t
well-documented.

To clarify, for a file_column field called “image” you need

  1. the plugin installed (which it looks like you’ve done, but
    double-check its permissions to make sure it’s readable to your
    webserver)

  2. a varchar/string field in your table for each class attribute you
    want to use with file_column, in your case named “image” (which gets
    filled automagically with the filename) and

  3. the declaration in the model (file_column :image) (which you’ve done
    right).

-sk

Hi Tom,

On 1/16/06, Tom S. [email protected] wrote:

My environement is Red Hat linux 9.0 with mysql 4.1. I installed
file_column under vendor/plugins. If I run “ls”, I get the following
directories:
file_column rails_file_column

hmm, that’s one directory too many. Please delete both directories and
make sure that everything from “trunk” lives in a “file_column”
directory in “vendor/plugins”, restart your web-server and try again.

After deleting all old file_column directories, you should be able to
install the files from “trunk” via the following command:

./script/plugin install
http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk

Hope this helps
Sebastian