Hide URL from view

Hi,
I have a button as below.
<%= button_to(‘On’, @userdetail.url + ‘?value=1’, :method => “post”,
:remote => true, :disable_with => ‘loading…’) %>
Here @userdetail.url is a external URL, and I don’t want to show the url
in
view source for users.

How can I create a controller action to do the task and point the button
to
that controller action? Tried implementing curl in my controller action
but
couldn’t make it work as this button action is a post method.

Any example help will help.
I am also trying to expose the button action as a API. Is there anyway I
can expose the same controller action as a API?

hara acharya wrote in post #1115165:

Hi,
I have a button as below.
<%= button_to(‘On’, @userdetail.url + ‘?value=1’, :method => “post”,
:remote => true, :disable_with => ‘loading…’) %>
Here @userdetail.url is a external URL, and I don’t want to show the url
in
view source for users.

What, are you trying to be sneaky and expose the user to web content
they never intended to visit? Not that this isn’t done all the time.
Especially when talking about inserted ads that are embedded in iframes.

How can I create a controller action to do the task and point the button
to
that controller action? Tried implementing curl in my controller action
but
couldn’t make it work as this button action is a post method.

The same way to define any controller action. Create a route for it. If
using a resources route you can add an additional RESTful action as
described in the documentation.

You don’t need curl. Ruby has a perfectly fine method for accessing
URIs:

Any example help will help.
I am also trying to expose the button action as a API. Is there anyway I
can expose the same controller action as a API?

A request is a request. It doen’t matter whether you send it with a
button, or with any other way of sending an HTTP request.