Reputation: 11799
I want to create a route such as
get '/referrals/send_invite/:email_address'
I will be calling this route via remote: true
and GET
. However if I issue the GET request in my browser, the route will still try to find a View, thus leading me to:
Template is missing
Is there a way that I could tell rails that the send_invite
method in Referrals Controller
doesn't have a view associated?
I would hope that this could be accomplished by just using rails routes.
Thanks.
Upvotes: 0
Views: 85
Reputation: 50057
Not completely sure, but I am guessing you want to start the action send_invite
so you are not interested in an actual result, correct?
You could do something like
def send_invite
SomeMailer.mail(:email => params[:email_address])
# or queue it or whatever
head :ok
end
Note that that is not the only option, you could also do something like
render :text => "The mail has been sent to #{params[:email_address]}"
or
render :json => {:result => 'ok', :email_adress => params[:email_address]}
Also note this should be a POST, since this action is not idempotent (a GET should not have side-effects).
Hope this helps.
Upvotes: 2
Reputation: 61
More likely than not your template missing is coming from not having a sendinvite.js.erb
. Try putting a blank one in your view folder
to see that sorts it out.
Upvotes: 0