Reputation: 3160
In a view I have included the link:
<%= link_to("Upgrade account", upgrade_path(@organization)) %>
This link exists on a standard 'show' view/page. So the visitor is already on for example http://localhost/organizations/123 with 123 being the @organization.id. So there is an @organization defined.
In the controller I have:
def upgrade
@organization = Organization.find(params[:id]) # This is the line that doesn't work
@actioncode = Actioncode.new
@amount = DEFAULT_PRICE
@currency = "EUR"
@description = @organization.id
@transaction_description = "MyDescription"
@transaction_type = "S"
@hash = hash(@description, @amount, @currency, @transaction_type)
render 'checkout'
end
However, when I click the link in development in the show view, I get the error message below.
No route matches [GET] "/signup/upgrade.123"
Does anyone have an idea what is going wrong? You would expect 'upgrade/123' but also if I manually change the address in the browser's address bar to 'upgrade/123' I get the same.
In routes I have:
post 'signup/upgrade' => 'organizations#upgrade', as: 'upgrade'
get 'signup/organization' => 'organizations#new', as: 'register'
get 'signup/register' => 'organizations#new_premium', as: 'register_premium'
post 'signup/register' => 'organizations#checkout', as: 'signup_checkout'
get 'signup/confirmation' => 'organizations#confirmation'
Upvotes: 0
Views: 34
Reputation: 479
Try updating your route to
post 'signup/upgrade/:id'
You can't test this url from the browser's address bar because that will submit a GET instead of a POST
Upvotes: 1
Reputation: 1963
you have route with post
and you are trying to get the url with get
.
btw: use rake routes
to see your routes
Upvotes: 0