Denis Orozco
asked on
How to get POST to show a page on ruby and rails
hi there,
Currently my application does display the page i want but when i click the button of submit i get this error:
Routing Error
No route matches [POST] "/result"
Try running rake routes for more information on available routes.
my routes.rb looks like this:
Adder::Application.routes. draw do
resources :posts
#...
End
and my controller looks like this:
class PostsController < ApplicationController
def index
end
# result method - fetch data and compute the sum
def result
# Fetch the form values
@first = params[:first].to_i
@second = params[:second].to_i
# Compute the sum
@sum = @first + @second
end
end
my question is how do enter the post record inside the routes.rb and where does my result page needs to live?
Thanks,
COHFL
Currently my application does display the page i want but when i click the button of submit i get this error:
Routing Error
No route matches [POST] "/result"
Try running rake routes for more information on available routes.
my routes.rb looks like this:
Adder::Application.routes.
resources :posts
#...
End
and my controller looks like this:
class PostsController < ApplicationController
def index
end
# result method - fetch data and compute the sum
def result
# Fetch the form values
@first = params[:first].to_i
@second = params[:second].to_i
# Compute the sum
@sum = @first + @second
end
end
my question is how do enter the post record inside the routes.rb and where does my result page needs to live?
Thanks,
COHFL
ASKER
rameshwar007,
Thanks for your reply but the redirect part is the one i'm having trouble with on my controller i have def result but is not going to my result.html.erb where dos this files goes? under ...\app\views\name_control ler\ or where exactly?
Thanks for your reply but the redirect part is the one i'm having trouble with on my controller i have def result but is not going to my result.html.erb where dos this files goes? under ...\app\views\name_control
This file will reside in the same posts but you need to add route for that action then can redirect to result page.
Hope this short note will help you.
Hope this short note will help you.
ASKER
ok if my controller has an entry like this
Def result
end
what would be the entry in the route table?
Def result
end
what would be the entry in the route table?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Best luck.