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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:00:57+00:00 2026-05-27T12:00:57+00:00

I have a model with a field called type and a field called value.

  • 0

I have a model with a field called “type” and a field called “value”. The type field will determine how the “value” is parsed before rendering. I want this to be easily extendible, so I’m putting a variety of “formatter” classes in my lib folder.

One of my “formatters” has a call to url_for:

class CustomTypeFormatter 
  include ActionView::Helpers::TextHelper
  include ActionView::Helpers

  def show
    raw sanitize( auto_link( value ) )
  end

  def get_url(page)
    url_for( :controller => :my_controller, :action => :show, :path => page.path )
  end

end

The problem is, url_for is raising this error:

undefined local variable or method `_routes'

I think I’m just missing an include. Does anyone have an idea what it should be?

**UPDATE***

Here’s part of the stack trace:

actionpack (3.0.7) lib/action_dispatch/routing/url_for.rb:131:in `url_for'
actionpack (3.0.7) lib/action_view/helpers/url_helper.rb:99:in `url_for'

So I think it must be some ActiveDispatch dependency, although I cannot figure out

  • 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-27T12:00:58+00:00Added an answer on May 27, 2026 at 12:00 pm

    Victory!

    include ActionView::Helpers
    include ActionDispatch::Routing
    include Rails.application.routes.url_helpers
    

    via http://apidock.com/rails/ActionController/UrlWriter

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model Question with a field called userid , before one ask
I have a field type in a model called user which is an int
I have a Model called statistics which has a value field that contains Goals
I have an ActiveRecord model with a field called name (in the database) and
Say I have a model object 'Person' defined, which has a field called 'Name'.
Let's say I have this model named Product with a field named brand .
Specifically, I have a model that has a field like this pub_date = models.DateField(date
I have a Rails Model called Events which has as field/attribute called :description. I
I have a field called force. Its by default a null field. I want
I have a problem when i try to create new model field type -

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.