Newbie error message!

hello you all,

I’m new with Ruby on Rails. I’m developing an application. I got the
follwoign erro, can anybody give a hand?

ArgumentError in AdminController#import_strings
wrong number of arguments (0 for 1)
RAILS_ROOT: ./script/…/config/…
Request
Parameters: {“commit”=>“Import”,
“description”=>{“description”=>#StringIO:0x36311f0},
“variable”=>[“English”]}

Show session dump


flash: !map:ActionController::Flash::FlashHash {}

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

This is my code (controller):

def import_strings(a_string)
table = { }
IO.foreach(’#{a_string}’) { |line|
if line =~ /^ \s* " (.?) " \s = \s* " (.*?) "/x
table[ $1 ] = $2

description = Description.new
description.Index_Number = [$1]
description.Name_Of_String = [$2]
description.save

end
}

This is my cod (view):

Importing Strings

<%= start_form_tag({:action => 'import_strings'}, :multipart => true)%>

Lenguage:
<%= select("variable", nil, @array_of_lenguages) %>

Path:
<%= file_field "description", "description"%>

<p><%= submit_tag "Import"%></p>

<%= end_form_tag%>

Your function takes one argument but your not passing it any from your
view.

Stephen wrote:

Your function takes one argument but your not passing it any from your
view.

Hi Stephen…thanks for your help. I’m trying to follow a books example
(uploading a picture) and they didn’t pass any parameters in thier view.
Rather they created an attribute in the model. This is what I did:

My controller code:

class UploadController < ApplicationController

def get
@description = Description.new
end

def save
@description = Description.new(params[:description])
if @description.save
redirect_to(:action=>‘show’, :id =>@description.id)
else
render(:action=>:get)
end
end
end

My model code:

class Description < ActiveRecord::Base

def import_strings(a_file)
table = { }
IO.foreach(’#{a_file}’) { |line|
if line =~ /^ \s* " (.?) " \s = \s* " (.*?) "/x
table[ $1 ] = $2
end
}

description = Description.new
description.Lenguage = [$1]
description.Platform = [$2]
description.save

end

def description=(description_field)
self.Index_Number = [$1]
self.Name_Of_String = [$2]

end
end

My view model:

Importing Strings

<%= start_form_tag({:action => 'save'}, :multipart => true)%>

Lenguage:
<%= select("variable", nil, @array_of_lenguages) %>

Path:
<%= file_field ("description", "description")%>

<p><%= submit_tag "Import"%></p>

<%= end_form_tag%>

I’m confused because the book uploads pictures but I want to upload
key-values read and parsed from an incoming file. Am I comparing two
things totally different? What step should I take.

thanks so much for your time