Hi guys..I did try almost everything..but still cant' get any result..

Starting from a simple "scaffold" creating a class called "reference"
I have updated the controller with this 2 methods:
--
  def load

  end

   def upload
    require 'fastercsv'
    filename = params[:file_tag]
    FasterCSV.foreach("public/trac/#{filename}",  {:col_sep => ";"} )
do |row|
   Reference.create(:idarticolo => row[0], :nomefilefoto => row[1],
                           :cancellato => row[2]    )
        end

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @reference }
    end
  end
--

the I've added a view file in the "app/view/reference" folder called
"load.html.erb"
with this code:

--
<h1>New reference</h1>
<%  form_for :reference, @references, :method => :get, :url =>
{:action => 'upload'} do %>

<p>Filename: <%= text_field_tag "file_tag" %> </p>

<p>  <%= submit_tag("Load csv") %></p>
<% end %>
<%= link_to 'Back', references_path %>
--

then I've updated the routes.rb file with this line (do I have to
replace the already in "map.resources :references" or do i add this
second new line?):
--
  map.resources :references, :collection => {"load" => "get"}
--

going to url: http://localhost:3000/references/load I get this error
message:
--
 ActiveRecord::RecordNotFound in ReferencesController#show

Couldn't find Reference with ID=load

RAILS_ROOT: /Users/adedip/Lavoro/antonioli1
Application Trace | Framework Trace | Full Trace

/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
base.rb:1586:in `find_one'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
base.rb:1569:in `find_from_ids'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
base.rb:616:in `find'
/Users/adedip/Lavoro/antonioli1/app/controllers/
references_controller.rb:25:in `show'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
flash.rb:146:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:606:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
routing/route_set.rb:437:in `call'
--

If I add any number at the end of the url it works perfectly (i.e.
http://localhost:3000/references/load/1 )

what am I doing wrong?
can someone explain me the process to get this work? thanks in
advance :)

Andrea

On 13 Mar, 05:34, RavionRails <ravindrasing...@gmail.com> wrote:
> just add
> map.resources :referenced , :collection => { 'new2' => 'get' }
>
> On Mar 12, 6:44 pm, Colin Law <clan...@googlemail.com> wrote:
>
> > On 12 March 2010 13:40, adedip <ade...@gmail.com> wrote:
>
> > > right!
> > > thx for reply..
> > > I'm going to read a basic restful/routes guide
>
> > In case you have not seem there there are excellent guides 
> > athttp://guides.rubyonrails.org/includingone on routing.  I would
> > suggest starting with Getting Started however which will explain the
> > basic principles of rails, then work through the others.
>
> > Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to