0

I have a controller method say

def my_method
 @gibbon = <data needed>
 render :something
end

and i have a URL say

http://exampleforme.com/example1

which returns a certain text, how to get this text inside my controller method from the URL?

I am using rails 2.8

4

2 回答 2

5

You could use Net::HTTP to get that URL as a string:

@gibbon = Net::HTTP.get(URI.parse("http://exampleforme.com/example1"))

See the API docs for more information.

Note: that this could impact your response time if that URL is slow to respond.

于 2013-05-02T08:17:27.660 回答
-2

can you show me your route file ?

but I think if you want "example1" text in url you can call params[:id] in your controller

@text = params[:id]
于 2013-05-02T08:35:32.987 回答