I know rails uses the controller action style urls like www.myapp.com/home/index
for example
I would like to have a url like this on my rails app, www.myapp.com/my_page_here
is this possible and if so how would I go about this?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
相关文章
- Ruby using wrong version of openssl
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- “No explicit conversion of Symbol into String” for
- form_for wrong number of arguments in rails 4
you just need to make a routing rule to match that url in this case it will be something like
your controller and action will specify the behavior of that page
so you could do
or
as suggested in other responses.
for index action in home controller if you have such a controller
see http://guides.rubyonrails.org/routing.html for more details
also see Ruby on Rails Routes - difference between get and match
You just use a
get
outside of anyresources
ornamespace
block in yourroutes.rb
file:Assuming you are using Rails 3+, do NOT use
match
. It can be dangerous, because if a page accepts data from a form, it should take POST requests.match
would allow GET requests on an action with side-effects - which is NOT good.Always use
get
,put
,post
or these variants where possible.To get a path helper, try:
That way, in your views,
my_page_path
will equalhttp://{domain}/my_page_here