Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7975701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:42:56+00:00 2026-06-04T08:42:56+00:00

Have a really basic question about rails – spent hours looking on the internet

  • 0

Have a really basic question about rails – spent hours looking on the internet for a solution – but can not find a solution.

I just need to call a method on the clicking of a link.

The idea is I need to export an xml file that is generated by a method in the controller.

firms_controller.rb (exerpt)

.....def xml
    @entries = Entry.find(:all)
    send_data @entries.to_xml,
    :type => 'text/xml; charset=UTF-8;',
    :disposition => "attachment; filename=entries.xml"
end....

I just need to call this method from the firms view page to get the xml file to download, but cannot manage to get it to work. The XML code does work – if I add it to the index method in the controller it works flawlessly.

This is some of the ways I have attempted to get the link working after reading some online articles.

<% url = url_for({:action => "xml", :controller => 'firms'}.merge(params)) %>
<%= link_to "XML", url %>

The most basic way tried

<%= link_to "XML", :action => 'xml' %>

It seems to me like something that should be very simple – but cannot get it to work.

The error I am getting:

ActiveRecord::RecordNotFound in FirmsController#show

Couldn't find Firm with ID=xml

Rails.root: /home/james/rails/KPSmart
Application Trace | Framework Trace | Full Trace

app/controllers/firms_controller.rb:25:in `show'

show method in firms_controller

  def show
  @firm = Firm.find(params[:id])
  end

Have tried messing with the routes to get it to work with no avail.

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:42:58+00:00Added an answer on June 4, 2026 at 8:42 am

    Try This

    In routes write this above your resource we written for firms controller

    match 'firms/xml', :controller => 'firms', :action => 'xml',:as => :firms_xml
    

    and link this in following way

    <%= link_to "XML", firms_xml_path %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have another SQL/access 2007 question that seems really basic but I'm not sure
I have really basic question. How can I get form id by input element
I realize this question is pretty basic, but I'm really stuck. I have a
G'day All, I am working in R. Sorry about this really basic question, but
I have a really basic question about jquery. However I don't know how to
I realize that this is probably a very basic question, but I have spent
This question must be really basic, but if you have any pointers I would
I have a really basic question concerning unix timestamp and mysql date. I'm trying
i have a question about basic mysql database optimisation. I have 3 tables, Articles,
I have a rather basic and general question about atomicity of UPDATE ... SET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.