Forum: Ruby on Rails file_column plugin error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ea44be95206beef3c6943907079bec89?d=identicon&s=25 Tom Snow (tomx)
on 2006-01-16 18:34
(Received via mailing list)
Hi,

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:in
`new'

/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:in
`load'
/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:in
`require_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:in
`require_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:in
`const_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:in
`perform_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:in
`perform_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:in
`perform_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:in
`send'
/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:in
`process'
/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:in
`handle_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:in
`service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in
`run'
/usr/local/lib/ruby/1.8/webrick/server.rb:155:in
`start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:144:in
`start'
/usr/local/lib/ruby/1.8/webrick/server.rb:144:in
`start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:94:in
`start'
/usr/local/lib/ruby/1.8/webrick/server.rb:89:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:89:in
`start'
/usr/local/lib/ruby/1.8/webrick/server.rb:79:in
`start'
/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:in
`dispatch'
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:in
`load'
/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:in
`require_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:in
`require_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:in
`const_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:in
`send'
/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:in
`perform_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:in
`measure'
/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:in
`perform_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: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:in
`process'
/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:in
`handle_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:in
`service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in
`run'
/usr/local/lib/ruby/1.8/webrick/server.rb:155:in
`start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:144:in
`start'
/usr/local/lib/ruby/1.8/webrick/server.rb:144:in
`start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:94:in
`start'
/usr/local/lib/ruby/1.8/webrick/server.rb:89:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:89:in
`start'
/usr/local/lib/ruby/1.8/webrick/server.rb:79:in
`start'
/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: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"}
Cf7e5e4b5ca573eec214191fac420a2f?d=identicon&s=25 Dave Silvester (Guest)
on 2006-01-16 19:14
(Received via mailing list)
On Monday 16 Jan 2006 17:32, Tom G wrote:
> Could anyone tell me why I got the error? It seems
> that rails can not
> find "file_column" plugin.

Hi Tom,

Having just set this up on a project today, here's what worked for me:

cd /path/to/my/rails/app
./script/plugin install http://opensvn.csie.org/rails_file_column/

Then, after that:

cd /vendor/plugins/rails_file_column/plugins/
mv file_column/ ../../
cd ..
rmdir plugins
cd ..
rmdir rails_file_column/

To be honest, I was just moving it for the sake of neatness (didn't like
the
deep nesting) but it seems to have worked, so no problems here.

One other thing I noticed that I can't seem to find documented anywhere,
is
that the...

<%= image_tag url_for_file_column "model_name", "column_name" %>

... stuff wasn't working, since it was returning a path that didn't
exist.

The path being returned included "development", eg:

/model_name/column_name/development/2/image_name.jpg

... when the actual path to the file was:

/model_name/column_name/2/image_name.jpg

... so what I did to address this was to go to my
/model_name/column_name
directory (inside public), and type:

ln -s . development

... which fixed it, but seems to be a slightly kludgy thing to do (and I
have
no idea what Windows users could do about this problem, but that's not
my
concern).

Anyway, it's working now, and this is for such a simple site that I'm
not
looking to spend long working out why some things are a little bit weird
with
the plugin!  The rmagick integration creating multiple resized versions
is
particularly sweet - I'm a happy little code monkey!  ;-)

~Dave

--

Dave Silvester
Rent-A-Monkey Website Development
Web: http://www.rentamonkey.com/
C204883ecbdf04c9a5bc9b024f5ed575?d=identicon&s=25 Bill Pennington (Guest)
on 2006-01-16 19:53
(Received via mailing list)
Thanks Dave a couple of litte nits

> cd /vendor/plugins/rails_file_column/plugins/

should be:

cd vendor/plugins/rails_file_column/plugins/

I also had to "mv vendor/plugins/file_column/tags/rel_0-3-1/* vendor/
plugins/file_column"

However I am still getting this when I try to display an uploaded image:

undefined method `url_for_file_column' for #<Entry:0x250a82c>

Any ideas?

On Jan 16, 2006, at 10:11 AM, Dave Silvester wrote:

> ./script/plugin install http://opensvn.csie.org/rails_file_column/
> To be honest, I was just moving it for the sake of neatness (didn't
> exist.
> column_name
> Anyway, it's working now, and this is for such a simple site that
>
> Dave Silvester
> Rent-A-Monkey Website Development
> Web: http://www.rentamonkey.com/
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>



- Bill
Cf7e5e4b5ca573eec214191fac420a2f?d=identicon&s=25 Dave Silvester (Guest)
on 2006-01-17 01:27
(Received via mailing list)
On Monday 16 Jan 2006 18:50, Bill Pennington wrote:
> Thanks Dave a couple of litte nits
> should be:
> cd vendor/plugins/rails_file_column/plugins/

D'oh, well spotted!  I cobbled together a few lines from my
.bash_history (to
make the instructions more concise) and I guess I mis-typed or
mis-pasted
that one.

> I also had to "mv vendor/plugins/file_column/tags/rel_0-3-1/* vendor/
> plugins/file_column"
> However I am still getting this when I try to display an uploaded image:
> undefined method `url_for_file_column' for #<Entry:0x250a82c>
> Any ideas?

Well, I did it differently to you - didn't move any specific tags /
trunk /
branches stuff, just moved the whole thing.

So:

dave@slynux $ pwd
/path/to/my/rails/app/vendor/plugins/file_column
dave@slynux $ ls
branches  tags  trunk
dave@slynux $ cd tags/
dave@slynux $ ls
rel_0-3  rel_0-3-1

Does that help?

Admittedly, I somewhat ignored part of the instructions and the wiki,
since I
wasn't quite sure the instructions exactly matched my setup / the
current
version of the plugin, so figured I'd try and do it myself, then see
what
broke.  Perhaps I should consider myself lucky that it worked first
time?

Does your app appear to be creating the images (inside public) when you
add
them?  If it's creating them but not downloading them, then I'm not
sure,
since that would mean the plugin was found OK (I think), but that
something
else is going wrong.  If it's not creating them, I guess that means the
plugin totally didn't work for you, so at least you know where to start
looking for a fix.

Only other thing I can think of is to make sure you're running the
latest gem
Rails version (or newer, I guess).  Here's my script/about for this app:

About your application's environment
Ruby version                 1.8.2 (i686-linux)
RubyGems version             0.8.11
Rails version                1.0.0
Active Record version        1.13.2
Action Pack version          1.11.2
Action Web Service version   1.0.0
Action Mailer version        1.1.5
Active Support version       1.2.5
Application root             /path/to/my/rails/app
Environment                  development
Database adapter             mysql

Each time I upgrade, I've got in the habit of uninstalling the old
versions of
my gems, so I only have one version of each installed.  I have no idea
if
this is necessary or even desirable, but it doesn't seem to have done me
any
harm so far.

Also, apologies for all this /path/to/my/rails/app stuff, I just prefer
not to
mention client names in public archived emails, just to be on the safe
side.

Cheers,

~Dave

--

Dave Silvester
Rent-A-Monkey Website Development
Web: http://www.rentamonkey.com/
C204883ecbdf04c9a5bc9b024f5ed575?d=identicon&s=25 Bill Pennington (Guest)
on 2006-01-21 15:40
(Received via mailing list)
>
> Well, I did it differently to you - didn't move any specific tags /
> trunk /
> branches stuff, just moved the whole thing.

When I tried that the plugin did not load at all.


> start
> looking for a fix.

Yes they upload and are on the filesystem as well as in the DB. I can
create and upload them just fine, even using RMajick to scale them.
Trying to load them back is where I get the issues. I am thinking I
might just be doing something stupid but I can't figure it out. I put
the model/view/controller code here - http://rafb.net/paste/results/
2sSPa676.html if your feeling generous enough to look it over I would
be forever indebted :-)

> Active Record version        1.13.2
> Action Pack version          1.11.2
> Action Web Service version   1.0.0
> Action Mailer version        1.1.5
> Active Support version       1.2.5
> Application root             /path/to/my/rails/app
> Environment                  development
> Database adapter             mysql

That all matches, thanks for checking.

> --
>
> Dave Silvester
> Rent-A-Monkey Website Development
> Web: http://www.rentamonkey.com/
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>



- Bill
Cf7e5e4b5ca573eec214191fac420a2f?d=identicon&s=25 Dave Silvester (Guest)
on 2006-01-21 15:44
(Received via mailing list)
On Monday 16 Jan 2006 20:16, Bill Pennington wrote:
> When I tried that the plugin did not load at all.

Fair enough.  :-)

> Yes they upload and are on the filesystem as well as in the DB. I can
> create and upload them just fine, even using RMajick to scale them.
> Trying to load them back is where I get the issues. I am thinking I
> might just be doing something stupid but I can't figure it out. I put
> the model/view/controller code here - http://rafb.net/paste/results/
> 2sSPa676.html if your feeling generous enough to look it over I would
> be forever indebted :-)

Instead of this in your view:

<% for entry in @entries %>
<%= entry.id %>
 <%= entry.url_for_file_column %>
<%= url_for_file_column( entry, "image") %>
<% end %>

... try something like this:

<% for @entry in @entries %>
<%= @entry.id %>
<%= image_tag url_for_file_column "entry", "image", "medium" %>
<% end %>

You need the @ on @entry, and you also missed which of your two images
you
were using, so it could have been either of those, or both!?

See the bit on the Wiki page about using this with iterators - "just a
note
about using url_for_file_column inside an iteration":

http://wiki.rubyonrails.com/rails/pages/HowToUseFileColumn

Any luck?  :-)

~Dave

--

Dave Silvester
Rent-A-Monkey Website Development
Web: http://www.rentamonkey.com/
C204883ecbdf04c9a5bc9b024f5ed575?d=identicon&s=25 Bill Pennington (Guest)
on 2006-02-24 18:45
(Received via mailing list)
Woohoo!! Thanks Dave, I owe you big time. For some reason I never
stumbled across that Wiki page ;-/

FYI if you don't specify what image it uses the original non-scaled
version from what I can tell.

On Jan 16, 2006, at 1:25 PM, Dave Silvester wrote:

>> 2sSPa676.html if your feeling generous enough to look it over I would
> ... try something like this:
> See the bit on the Wiki page about using this with iterators -
>
> Dave Silvester
> Rent-A-Monkey Website Development
> Web: http://www.rentamonkey.com/
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>



- Bill
This topic is locked and can not be replied to.