regarding routes

5 views
Skip to first unread message

nike ed

unread,
Oct 15, 2012, 4:44:37 AM10/15/12
to rubyonra...@googlegroups.com
I have a controller with only one action "res" . I need to redirect to
this controller file for decrypting the code ,so can the url to this be

1) "http://..........:3000/user_controller.rb?DR={DR}"

(OR)

2) "http://..........:3000/user/res?DR={DR}"


is their any possibility of having url as in (1)

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

Walter Lee Davis

unread,
Oct 15, 2012, 11:40:51 AM10/15/12
to rubyonra...@googlegroups.com

On Oct 15, 2012, at 4:44 AM, nike ed wrote:

> I have a controller with only one action "res" . I need to redirect to
> this controller file for decrypting the code ,so can the url to this be
>
> 1) "http://..........:3000/user_controller.rb?DR={DR}"
>
> (OR)
>
> 2) "http://..........:3000/user/res?DR={DR}"
>
>
> is their any possibility of having url as in (1)

I don't believe it is at all possible to have 1, but 2 is certainly do-able. Have a read through the Rails Guide: Routing from the Outside In. It covers the details of creating routes for nearly any URL you might want to handle.

I suppose you *could* make the URL read user_controller.rb if you wanted to, it's just a text string after all, but remember back to when you set up Apache or another Web server for your Rails hosting. The "site root" (publicly exposed directory, from Apache's point of view) is the /yourapp/public folder. All of your controllers are at /yourapp/app/controllers -- completely outside of the public folder, therefore not directly addressable by an external URL.

So while you could make a route respond to your #1 URL, in no way would the actual request be going directly to that controller file in the app/controllers folder -- it would be treated as any other synthetic URL in the Rails system, parsed for its meaning and directed by a "front controller" to the appropriate controller according to the rules of routing.

Walter

>
> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages