For starters, your form tag points at an action called ''save'',
and all your
code is in an action called ''import_strings''. Unless you left
some other
code out, your method won''t be called by this form.
Also I don''t think you''re quite understanding what will come
in from your
form field parameter. Might want to have a look at:
http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles
HTH,
Jeff
On 7/25/06, David Furgeson <ricardo.orozco@hp.com>
wrote:>
> Hello there,
>
> I''m new with ruby on rails and i don''t know how to load
up a parsed file
> into my database. I have my ruby script that parses it but don''t
know
> where to put my code, or how to combine it with view/model/controller.
> this is what i have:
>
> 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
>
> end
>
> My view:
>
> <h1>Importing Strings<h1>
>
> <%=error_messages_for("description")%>
> <%= start_form_tag({:action => ''save''}, :multipart
=> true)%>
> <p>
> <b>Lenguage:</b><br/>
> <%= select("variable", nil, @array_of_lenguages)
%>
> </p>
> <p>
> <b>Path: </b><br />
> <%= file_field ("description", "description"
> )%>
> </p>
> <p><%= submit_tag "Import"%></p>
>
> <%= end_form_tag%>
>
> I only get the actual displays but the file is never loaded into the
> database. Does anybody know why?
>
> Any help is apreciated
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060726/e8bfc7f7/attachment.html