Using routes.rb from inside a controller / render_component_

Hi,

In an action I have a string representing a url for a get request. A
simple and seemingly ridiculous example might be something like the
following. What I’m trying to do is much more complicated but I think
this tiny example shows where I am stuck.

Into their browser a user types
http://my.domain.com/admin/category/updates”. I have a controller
roughly like the following

class Admin::CategoryController < ApplicationController

def updates
# a url for a get request that isn’t actually hard coded like this
example
url = “/admin/category/info/1”

# the following line is the tricky one.
str = get(url)

render :text=>str

end

def info
@category = Category.find(params[:id])
end
end

The “tricky” line needs to use config/routes.rb to parse the url and
create the params hash if a ‘?’ is in the url. The info action must
execute with the same session.

I’m sure I could somehow use render_component_as_string; however, I
don’t know how to access config/routes.rb to parse the url string to
prepare the arguments for render_component_as_string.

Any ideas?

I’ve been struggling with this on and off for a couple months and have
asked here in a variety of forms. Any help greatly appreciated.

Thanks,
Peter

And why do i get a “Route uninitialized constant” error when I try this

require “action_controller/routing.rb”

class Admin::CategoryController < ApplicationController

def updates
session[:asdf]=Route.new("/admin/category/info/1")
end

end

Thanks,
Peter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs