Forum: Ruby on Rails Application doesn't work on two different machines

Posted by Heinz Strunk (cojones)
on 2009-07-02 15:31
Hello,

I've got an application which I am developing on a Windows machine and
everything works just fine. Once I upload it on my server (Debian) and
test it I get following error:
ActionView::TemplateError (undefined local variable or method `filename'
for #<News:0x41105540>) on line #8 of news/index.html.erb:
5:              </tr>
6:              <tr>
7:                      <td class="news_table_pic">
8:                              <%= image_tag(news.public_filename)
%><br>
9:                              Erstellt am <%=
news.created_at.strftime("%d.%m.%Y") %><br>
10:                             von <%=h news.author %>
11:                     </td>

I'm using attachment_fu.

Anyone knows why it doesn't work on my debian machine?

Thanks
Posted by Alpha Blue (elricstorm)
on 2009-07-02 15:54
Start by making sure you are running the exact same versions of both 
ruby and rails.  Make sure all of your gems and gem versions are the 
same.  Make sure you are including rubygems (require 'rubygems') before 
requiring your gems in environment.rb to make sure there are no 
conflicts.

I personally go through my production server and run an irb require test 
on every gem I use on development..

irb
> require 'rubygems'
> require 'name of gem'
> require 'name of next gem'
=> all should come as 'true'

After you've done that, read the following regarding the image paths you 
are having trouble with:

http://www.ruby-forum.com/topic/164189

Your issue and his are similar.
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-02 16:50
(Received via mailing list)
It looks like you are using a plugin such as attachment_fu. Ensure
that you have that included in your deployment to production.

Cheers,
Nicholas


On Jul 2, 9:31 am, Heinz Strunk <rails-mailing-l...@andreas-s.net>
Posted by Heinz Strunk (cojones)
on 2009-07-02 16:56
Yeah, it's gotta be something to do with attachment_fu cause I'm calling 
a attachment_fu function.
I just realized that my Windows machine has rmagick (2.9.0) installed 
and Debian rmagick (1.15.0). That could be the reason right?

Just gotta figure out how to update rmagick then...
checking for wand/MagickWand.h... no
Can't install RMagick 2.10.0. Can't find MagickWand.h.

Wrong forum I know but anybody knows what the heck is going on there?
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 16:32
(Received via mailing list)
1. I wouldn't have thought the RMagick version would have mattered,
can you confirm the attachment_fu is being deploy to your production
environment?

2. Perhaps try upgrading imagemagick first before installing rmagick.

Cheers,
Nicholas


On Jul 2, 10:56 am, Heinz Strunk <rails-mailing-l...@andreas-s.net>
Posted by Heinz Strunk (cojones)
on 2009-07-03 17:26
Nicholas Henry wrote:
> 1. I wouldn't have thought the RMagick version would have mattered,
> can you confirm the attachment_fu is being deploy to your production
> environment?
attachment_fu is inside the plugins folder so should be alright=
> 2. Perhaps try upgrading imagemagick first before installing rmagick.
i updated imagemagick by compiling and installing it manually but now i 
get this error message
> Cheers,
> Nicholas
> 
> 
> On Jul 2, 10:56�am, Heinz Strunk <rails-mailing-l...@andreas-s.net>
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 17:43
(Received via mailing list)
Putting aside the RMagick issue (can't really help you there), do you
have the full error trace for:

ActionView::TemplateError (undefined local variable or method
`filename'
for #<News:0x41105540>) on line #8 of news/index.html.erb:

On Jul 3, 11:26 am, Heinz Strunk <rails-mailing-l...@andreas-s.net>
Posted by Heinz Strunk (cojones)
on 2009-07-03 17:54
Yes:
ActionView::TemplateError (undefined local variable or method `filename' 
for #<News:0x40f5a7a4>) on line #8 of news/index.html.erb:
5:   </tr>
6:   <tr>
7:    <td class="news_table_pic">
8:     <%= image_tag(news.public_filename) %><br>
9:     Erstellt am <%= news.created_at.strftime("%d.%m.%Y") %><br>
10:     von <%=h news.author %>
11:    </td>

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:256:in 
`method_missing'
    vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:233:in 
`thumbnail_name_for'
    vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in 
`full_filename'
    vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:43:in 
`public_filename'
    app/views/news/index.html.erb:8:in 
`_run_erb_47app47views47news47index46html46erb'
    app/views/news/index.html.erb:1:in `each'
    app/views/news/index.html.erb:1:in 
`_run_erb_47app47views47news47index46html46erb'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:338:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:338:in 
`execute'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/template_handlers/compilable.rb:29:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/template_handlers/compilable.rb:29:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/template.rb:35:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/template.rb:22:in 
`render_template'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:245:in 
`render_file'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1108:in 
`render_for_file'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:865:in 
`render_with_no_layout'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:880:in 
`render_with_no_layout'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/layout.rb:251:in 
`render_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:51:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/benchmark.rb:8:in 
`realtime'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:51:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:131:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:131:in 
`custom'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:160:in 
`call'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:160:in 
`respond'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:154:in 
`each'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:154:in 
`respond'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/mime_responds.rb:107:in 
`respond_to'
    app/controllers/news_controller.rb:22:in `index'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in 
`perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:580:in 
`call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:573:in 
`perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:68:in 
`perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/benchmarking.rb:68:in 
`perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/rescue.rb:201:in 
`perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/sql_cache.rb:13:in 
`perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in 
`cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/query_cache.rb:8:in 
`cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/caching/sql_cache.rb:12:in 
`perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:529:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:529:in 
`process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/filters.rb:569:in 
`process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/session_management.rb:130:in 
`process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:389:in 
`process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:149:in 
`handle_request'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in 
`dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in 
`synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in 
`dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:120:in 
`dispatch_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in 
`dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in 
`process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 
`synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 
`process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in 
`process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in 
`each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in 
`process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 
`initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 
`new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 
`initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 
`new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 
`each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in 
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/bin/mongrel_rails:19:in `load'
    /usr/local/bin/mongrel_rails:19

Rendering /var/www/web/htdocs/releases/20090612181632/public/500.html 
(500 Internal Server Error)
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 18:01
(Received via mailing list)
Which version of rails are you developing with locally?

On Fri, Jul 3, 2009 at 11:54 AM, Heinz
Posted by Heinz Strunk (cojones)
on 2009-07-03 18:05
Local Windows machine:
Rails 2.2.2
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
gem 1.3.2

Debian machine (not working on this machine):
Rails 2.2.2
ruby 1.8.7 (2008-05-31 patchlevel 0) [i686-linux]
gem 1.3.1
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 18:09
(Received via mailing list)
I think in your production environment you are using an older version
of Rails (review your error trace):

/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/

You should vendor your rails with your application to avoid this in the 
future.

Looks like it's an incompatibility with the version of attachment_fu
and active-record/rails.

Cheers,
Nicholas

On Fri, Jul 3, 2009 at 12:05 PM, Heinz
Posted by Heinz Strunk (cojones)
on 2009-07-03 18:43
Hey,

I was running 2.1.0 on my local machine as well but I updated it to 
2.2.2 but with no effect:
ActionView::TemplateError (undefined local variable or method `filename' 
for #<News:0x40ec017c>) on line #8 of app/views/news/index.html.erb:
5:   </tr>
6:   <tr>
7:    <td class="news_table_pic">
8:     <%= image_tag(news.public_filename) %><br>
9:     Erstellt am <%= news.created_at.strftime("%d.%m.%Y") %><br>
10:     von <%=h news.author %>
11:    </td>

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb:260:in 
`method_missing'
    vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:233:in 
`thumbnail_name_for'
    vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:21:in 
`full_filename'
    vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:43:in 
`public_filename'
    app/views/news/index.html.erb:8
    app/views/news/index.html.erb:1:in `each'
    app/views/news/index.html.erb:1
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in 
`render_template'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:367:in 
`_render_with_layout'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:254:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in 
`render_for_file'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:905:in 
`render_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in 
`realtime'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in 
`render'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:135:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:135:in 
`custom'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:164:in 
`call'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:164:in 
`respond'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:158:in 
`each'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:158:in 
`respond'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:107:in 
`respond_to'
    app/controllers/news_controller.rb:22:in `index'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in 
`perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in 
`call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in 
`perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in 
`perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in 
`perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in 
`perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in 
`perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in 
`cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:in 
`cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in 
`perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in 
`send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in 
`process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:in 
`process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in 
`process'
...

Any other ideas?
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 18:49
(Received via mailing list)
Have you tried updating attribute_fu? Where did you source it from?

On Fri, Jul 3, 2009 at 12:43 PM, Heinz
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 18:49
(Received via mailing list)
I meant attachment_fu
Posted by Heinz Strunk (cojones)
on 2009-07-03 18:55
I just updated attachment_fu and did a db:migrate:reset and now 
everything works like a charm :) Thank you!
Posted by Nicholas Henry (nicholas-henry)
on 2009-07-03 18:59
(Received via mailing list)
OK, could have been a version conflict between Rails and
attachment-fu. One thing I didn't think of asking was to ensure you
had run the migrations in production. Pleased to hear you are good to
go.

Cheers,
Nicholas


On Fri, Jul 3, 2009 at 12:55 PM, Heinz
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.