JamesRocky
JamesRocky

Reputation: 721

How does redirect work in rails?

I don't have a /charge page. But I do have a subscription/charge page. I was wondering, how do I say, "if a user goes to /charge, redirect them to subscription/charge" using routes

No route matches [POST] "/charged"

Upvotes: 0

Views: 80

Answers (2)

Stef Hej
Stef Hej

Reputation: 1377

you can also write:

root 'subscription#charge'

and you'll be redirected to the charge page if accessing http://localhost:3000

Upvotes: 1

user1801879
user1801879

Reputation: 822

You can modify your routes.rb file to point a url to a specific action

get '/charge', to: 'subscription#charge'

I'm using something similar to below in my application for post:

 match '/charge' => 'subscription#charge', :via => [:post], :as => :subscription_charge

Upvotes: 2

Related Questions