Hi, everyone. I'm working on a program in Rails 3.0.10 and it has a
custom action, "run_files", that extracts data in files and saves it in
database. When I clicked the link on the page, it returned an error
page:
ActiveRecord::RecordNotFound in ReportsController#show
Couldn't find Report with ID=run_files

I wonder why Rails rendered show instead of the custom action.
Following is the view file, route file and the output of rake routes.

index.html.erb
<%= link_to "Process Files", :controller => 'reports', :action =>
'run_files' %>

routes.rb
match "reports/run_files" => "reports#run_files", :via => :post
resources :reports

output of rake routes
reports_run_files POST /reports/run_files(.:format)
{:controller=>"reports"
, :action=>"run_files"}
...
..

Thanks in advance.

--
Posted via http://www.ruby-forum.com/.

--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Tim Shaffer at Sep 21, 2011 at 7:39 pm
    You have the route specified to only accept POST requests, but by using
    link_to, you're creating a hyperlink that generates a GET request.

    You'll need to either change your routes to accept a GET request, or change
    your method of calling the URL to a POST request (from a form).

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/x5f-5kq1mO4J.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Ichiro Saga at Sep 21, 2011 at 9:07 pm

    Tim Shaffer wrote in post #1023170:
    You have the route specified to only accept POST requests, but by using
    link_to, you're creating a hyperlink that generates a GET request.

    You'll need to either change your routes to accept a GET request, or
    change
    your method of calling the URL to a POST request (from a form).
    Thanks Tim. I tried both and they work! But I noticed that it
    generated one more sql query when a GET request's sent than that when a
    POST request's sent.
    <-[1m<-[35mSQL (0.0ms)<-[0m SELECT name FROM sqlite_master WHERE
    type = 'table' AND NOT name = 'sqlite_sequence'

    Where is it from and is it possible to skip it?

    --
    Posted via http://www.ruby-forum.com/.

    --
    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-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Tim Shaffer at Sep 22, 2011 at 12:15 pm
    That query is nothing to worry about. It's just rails running a query to
    figure out which tables you have in your database so it can figure out which
    columns they have so it can make your models work properly.

    In production it should only run once (when the server is first started).
    But then again you probably shouldn't be using sqlite in production.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 21, '11 at 6:58p
activeSep 22, '11 at 12:15p
posts4
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Ichiro Saga: 2 posts Tim Shaffer: 2 posts

People

Translate

site design / logo © 2021 Grokbase