Argument Error?

View layer:

<%= thumbnail_tag (@content_page.picture1), :border => 0, :width => 489,
:height => 236 %>

Helper layer:

def thumbnail_tag(picture, options = {})
  link_to(scale_image_tag(picture, options.merge({:border => 0})),
"/settings/view_image/#{picture.id}", :popup => ["_blank",
"width=#{picture.width+15},height=#{picture.height + 10}"])
end

Can someone help me diagnose this problem?

What method is it saying has too many arguments? The call to
'thumbnail_tag' or to 'scale_image_tag' or to 'link_to'?

Michael Pavling wrote:
> What method is it saying has too many arguments? The call to

'thumbnail_tag' or to 'scale_image_tag' or to 'link_to'?

Apologies. thumbnail_tag is throwing the error.

Really? Strange.
What happens if you try to call thumbnail_tag with no arguments?

Michael Pavling wrote:

Really? Strange.
What happens if you try to call thumbnail_tag with no arguments?

I get exactly the same error. I don't see the logic in this problem.
Hence my post.

Can you post a few extra lines from the error messages you get in both
cases; I'm curious if they're *exactly* the same...

Michael Pavling wrote:

Michael Pavling wrote:

Really? Strange.
What happens if you try to call thumbnail_tag with no arguments?

I get exactly the same error. I don't see the logic in this problem.
Hence my post.

Can you post a few extra lines from the error messages you get in both
cases; I'm curious if they're *exactly* the same...

Case 1 (with arguments):

wrong number of arguments (2 for 0)

Extracted source (around line #2):

1: <% if @content_page.has_picture1? %>
2: <%= thumbnail_tag @content_page.picture1, :border => "0", :width =>
"288" %>
3: <% else %>
4: <% if File.exists?("#{RAILS_ROOT}/public/images/default_image.jpg")
%>
5: <%= image_tag "default_image.jpg", :border => "0", :width =>
"288" %>

Case 2 (without arguments):

wrong number of arguments (2 for 0)

Extracted source (around line #2):

1: <% if @content_page.has_picture1? %>
2: <%= thumbnail_tag @content_page.picture1 %>
3: <% else %>
4: <% if File.exists?("#{RAILS_ROOT}/public/images/default_image.jpg")
%>
5: <%= image_tag "default_image.jpg", :border => "0", :width =>
"288" %>

No, sorry; I meant the stack trace message that tells you which lines
of which files were executing.
If it's easier, maybe just past the whole message into a pastebin
service (http://gist.github.com/ or http://pastebin.com/ etc)

Michael Pavling wrote:

No, sorry; I meant the stack trace message that tells you which lines
of which files were executing.
If it's easier, maybe just past the whole message into a pastebin
service (http://gist.github.com/ or http://pastebin.com/ etc)

Apologies - here are the full stack traces.

Case 1 (with arguments):

vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in
`url'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in
`send'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in
`method_missing'
app/helpers/application_helper.rb:44:in `scale_image_tag'
app/helpers/application_helper.rb:51:in `thumbnail_tag'
app/views/web/_layout1_content.rhtml:2:in
`_run_erb_47app47views47web47_layout1_content46rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`render'
vendor/rails/actionpack/lib/action_view/partial_template.rb:20:in
`render'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
`benchmark'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
`benchmark'
vendor/rails/actionpack/lib/action_view/partial_template.rb:19:in
`render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in
`render_template'
vendor/rails/actionpack/lib/action_view/partials.rb:110:in
`render_partial'
vendor/rails/actionpack/lib/action_view/base.rb:273:in `render'
app/views/web/content2.rhtml:1:in
`_run_erb_47app47views47web47content246rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in
`render_template'
vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
vendor/rails/actionpack/lib/action_controller/base.rb:1108:in
`render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:841:in
`render_with_no_layout'
vendor/rails/actionpack/lib/action_controller/layout.rb:251:in
`render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/actionpack/lib/action_controller/base.rb:1157:in
`default_render'
vendor/rails/actionpack/lib/action_controller/base.rb:1168:in
`perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:580:in
`call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:573:in
`perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in
`perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
`cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in
`process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:569:in
`process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in
`process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in
`handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in
`dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in
`dispatch'
vendor/rails/railties/lib/fcgi_handler.rb:103:in `process_request'
vendor/rails/railties/lib/fcgi_handler.rb:153:in `with_signal_handler'
vendor/rails/railties/lib/fcgi_handler.rb:101:in `process_request'
vendor/rails/railties/lib/fcgi_handler.rb:78:in `process_each_request'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:117:in `session'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:104:in `each_request'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:36:in `each'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
vendor/rails/railties/lib/fcgi_handler.rb:77:in `process_each_request'
vendor/rails/railties/lib/fcgi_handler.rb:76:in `catch'
vendor/rails/railties/lib/fcgi_handler.rb:76:in `process_each_request'
vendor/rails/railties/lib/fcgi_handler.rb:50:in `process!'
vendor/rails/railties/lib/fcgi_handler.rb:24:in `process!'
dispatch.fcgi:24

Case 2 (without arguments):

vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in
`url'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in
`send'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in
`method_missing'
app/helpers/application_helper.rb:44:in `scale_image_tag'
app/helpers/application_helper.rb:51:in `thumbnail_tag'
app/views/web/_layout1_content.rhtml:2:in
`_run_erb_47app47views47web47_layout1_content46rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`render'
vendor/rails/actionpack/lib/action_view/partial_template.rb:20:in
`render'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
`benchmark'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:26:in
`benchmark'
vendor/rails/actionpack/lib/action_view/partial_template.rb:19:in
`render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in
`render_template'
vendor/rails/actionpack/lib/action_view/partials.rb:110:in
`render_partial'
vendor/rails/actionpack/lib/action_view/base.rb:273:in `render'
app/views/web/content2.rhtml:1:in
`_run_erb_47app47views47web47content246rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in
`render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in
`render_template'
vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
vendor/rails/actionpack/lib/action_controller/base.rb:1108:in
`render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:841:in
`render_with_no_layout'
vendor/rails/actionpack/lib/action_controller/layout.rb:251:in
`render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/actionpack/lib/action_controller/base.rb:1157:in
`default_render'
vendor/rails/actionpack/lib/action_controller/base.rb:1168:in
`perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:580:in
`call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:573:in
`perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in
`perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in
`cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in
`process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:569:in
`process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in
`process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in
`handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in
`dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in
`dispatch'
vendor/rails/railties/lib/fcgi_handler.rb:103:in `process_request'
vendor/rails/railties/lib/fcgi_handler.rb:153:in `with_signal_handler'
vendor/rails/railties/lib/fcgi_handler.rb:101:in `process_request'
vendor/rails/railties/lib/fcgi_handler.rb:78:in `process_each_request'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:117:in `session'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:104:in `each_request'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:36:in `each'
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
vendor/rails/railties/lib/fcgi_handler.rb:77:in `process_each_request'
vendor/rails/railties/lib/fcgi_handler.rb:76:in `catch'
vendor/rails/railties/lib/fcgi_handler.rb:76:in `process_each_request'
vendor/rails/railties/lib/fcgi_handler.rb:50:in `process!'
vendor/rails/railties/lib/fcgi_handler.rb:24:in `process!'
dispatch.fcgi:24

To add to that, here is the scale_image_tag helper method:

def scale_image_tag(picture, options = {})
  if picture
# raise options.to_yaml
    image_tag(picture.url(options[:width], options[:height]),
options.merge({:alt => picture.image_alt, :title => picture.image_alt}))
  else
    image_tag("clear.gif", options)
  end
end

Pastebin! Save the list's bandwith and our eyes! :wink:

Anyway; they're both complaining about 'scale_image_tag'...
    app/helpers/application_helper.rb:44:in `scale_image_tag'

I'd stick some breakpoints on there, and see what's happening.

Michael Pavling wrote:

Pastebin! Save the list's bandwith and our eyes! :wink:

Anyway; they're both complaining about 'scale_image_tag'...
    app/helpers/application_helper.rb:44:in `scale_image_tag'

I'd stick some breakpoints on there, and see what's happening.

Solved. Thanks for your advice.

Do you fancy letting the list know what the solution was? ... it may
help someone else in future.

Michael Pavling wrote:

Do you fancy letting the list know what the solution was? ... it may
help someone else in future.

Erroneous:

  def scale_image_tag(picture, options = {})
    if picture
      #raise options.to_yaml
      image_tag(picture.url(options[:width], options[:height]),
options.merge({:alt => picture.image_alt, :title => picture.image_alt}))
    else
      image_tag("clear.gif", options)
    end
  end

  def thumbnail_tag(picture, options = {})
    link_to(scale_image_tag(picture, options.merge({:border => 0})),
"/settings/view_image/#{picture.id}", :popup => ["_blank",
"width=#{picture.width+15},height=#{picture.height + 10}"])
  end

Working:

  def scale_image_tag(picture, options = {})
    if picture
      image_tag(Picture.image_url(picture.resize(options[:width],
options[:height])), options.merge({:alt => picture.image_alt, :title =>
picture.image_alt}))
    else
      image_tag("clear.gif", options)
    end
  end

  def thumbnail_tag(picture, options = {})
    link_to(scale_image_tag(picture, options.merge({:border => 0})),
{:controller => 'settings', :action => 'view_image', :id => picture},
:popup => ["_blank", "width=#{picture.width+15},height=#{picture.height
+ 10}"])
  end

Michael Pavling wrote: