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 828867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:47:36+00:00 2026-05-15T03:47:36+00:00

I have the following partial. It can be called from three different times in

  • 0

I have the following partial. It can be called from three different times in a view as follows:

 <%= render :partial => "contact_event",
     :collection => @contacts,
        :locals => {:event => email} %>

Second time:

 <%= render :partial => "contact_event",
     :collection => @contacts,
        :locals => {:event => call} %>

Third time:

 <%= render :partial => "contact_event",
     :collection => @contacts,
        :locals => {:event => letter} %>

In each instance, call, email, letter refer to a specific instance of a Model Call, Email, or Letter.

Here is what I tried to do and conceptually what I’d like to do: assign the route based on the class name that has been passed to the :event from the :partial.

What I did was create what the actual url should be. The ‘text’ of it is correct, but doesn’t seem to recognize it as a named route.

 <!-- provide a link to skip this item -->
 <% url = "skip_contact_#{event.class.name.tableize.singularize}_url" %>
 <%= link_to_remote "Skip #{url} Remote",
    :url => send("#{url}(contact_event, event)")
    :update => "update-area-#{contact_event.id}-#{event.id}" %>
 <span id='update-area-<%="#{contact_event.id}-#{event.id}"%>'> </span>

The result of the above: when event has been passed an email instance, for example, it says:

skip_contact_email_url not a method.

The url is right, but it doesn’t recognize as a method.

  1. How can I dynamically define skip_contact_email_url to be skip_contact_letter_url if the local variable is letter?

  2. Even better, how can I have a single named route that would do the appropriate action?

  • 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-05-15T03:47:37+00:00Added an answer on May 15, 2026 at 3:47 am

    You can use polymorphic_url. It generates corresponding route based on item types:

    Edit: The route is generated based on record’s class, so if you pass :event => call or :event => email, it will work like this:

    # event.class == Email
    polymorphic_url([contact_event, event], :action => :skip)
    #=> /contact_events/:contact_event_id/emails/:id/skip
    
    # event.class == Call
    polymorphic_url([contact_event, event], :action => :skip)
    #=> /contact_events/:contact_event_id/calls/:id/skip
    

    etc.

    Edit2:
    Routes:

    map.resources :contacts do |contact|
      contact.with_options :member => {:skip => : ... [get/post - what you have] } do |c|
        c.resources :letter
        c.resources :emails
        c.resources :calls
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial that renders a select box using the following method: <%=
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have a visual studio website solution with the following structure A page called
I have the following structure: Views: Home Articles Partial Views: Book Classes Intro Faq
I have the following array and can't figure out how to get the data
I have the following Class which basically creates a list of categories (called commands,
Let me explain what I want. I have the following (partial) HTML. <ul> <li
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,

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.