Rails dot instead of slash in URL
projects_path
is the index, which only takes one argument: the format. You want project_path(1)
URL changes into dot instead of slash
You appear to have the rooms
resource defined twice:
resources :rooms, only: [:index, :show]
resources :photos
resources :rooms do
resources :reservations, only: [:create]
end
You can consolidate that:
resources :photos
resources :rooms, only: [:index, :show] do
resources :reservations, only: [:create]
end
I'm not 100% sure that will fix your issue, but it's the first thing I'd try.
Path helpers generate paths with dots instead of slashes
Yes, this is a pluralization error.
By passing the ID 1, I assume that you wish to display a single record.
So you need to use the singular 'message_thread':
message_thread_path(1)
Which will yield:
http://localhost:3000/message_threads/1
URL link gives dot instead of slash
Looks like this is a pluralization error.
Try
cars_payment_path
instead of
car_payments_path
rails named route puts '.' instead of '/' in URL on updating
As described in this question, typically the issue is when you confuse between collection (plural) and member (singular) controller actions.
A collection controller action is an action that does not have an ID since it does not manipulate an existing resource (dash
) or since it works on a group of resources. The RESTful collection actions are: index
, new
, and create
. Each of them has a helper method and a "verb" (method):
index
:url: dashes_path, method: :get
(method get is default)create
:url: dashes_path, method: :post
new
:url: new_dash_path, method: :get
Note how both index
and create
share the same plural URL helper method dashes_path
. Only the method
option differentiates between them.
A member controller action is an action that has an ID of the resource it is manipulating (one particular dash
). The RESTful collection actions are:
edit
:url: edit_dash_path(@dash), method: :get
show
:url: dash_path(@dash), method: :get
update
:url: dash_path(@dash), method: :patch
destroy
:url: dash_path(@dash), method: :destroy
See how except edit
, all other actions use the same singular URL helper method dash_path(@dash)
.
You can find further details on this in the guides.
Now, the "dot instead of slash" symptom is when you mistakenly try to point to a member action in a way that should be used for collection actions. So if you try to do dashes_path(@dash)
- there is no such thing. The only parameter dashes_path
accepts is format
, which is added to the URL in the end after a dot, that's why you're seeing a weird URL such as /dash.6
.
Rails form builder form_for
and extensions such as simple_form_for
need to decide whether to point the form action at the #create
collection action (when rendering the #new
collection action) or #update
member action (when rendering the #edit
member action). They do so "magically" by taking a look at the object you give them when you do simple_form_for(@dash)
. If @dash.new_object?
is true, they point the form action to #create
, if it's false they point it to #update
.
In your case when you used it "out of the box" it was all good. It started acting up on you when you added this line to your routes.rb
:
get 'dash', to: 'dashes#show'
By default show
is a member action, not a collection action. It must receive an ID. I think that this is why Simple Form is acting up on you. Instead of that alias, try this one:
get 'dash/:id', to: 'dashes#show'
Let us know if this fixes the issue.
And in general, I recommend to "work with" the RESTful routing rather then "working against" them. It is very rare to need to add named routes in routes.rb
. There are exceptions, but I don't think it is justified in your case to deviate from conventions and try to use dash/1
rather than dashes/1
. "Working with" Rails will get you the productivity boost it is known for, not "working against" it by trying to force it for relatively small details like this one.
Rails app ending in dot id versus slash, how to get slash route?
Try using user_bookings_path(user, booking)
.
Rails's link_to return url with dot instead of slash
I think you should remove the
match '/order', :to => ...
from your routes file.
Url without slash, dot words in it
You can achieve this with gsub:
"bike-2-dot-2-slash-2-dot-0".gsub(/-(dot|slash)/, '')
Related Topics
How to Match Something With Regex That Is Not Between Two Special Characters
Shortcut to Make Case/Switch Return a Value
Rails - Render :Action to Target Anchor Tag
The <<- Operator on Ruby, Where Is It Documented
Character Encoding Issue in Rails V3/Ruby 1.9.2
Looking For Suggestions For Building a Secure Rest API Within Ruby on Rails
Gem Eventmachine Fatal Error: 'Openssl/Ssl.H' File Not Found
Netbeans and Rails Error: Bin/Ruby: No Such File or Directory -- Script/Rails (Loaderror)
Rails: Specified 'Mysql2' for Database Adapter But the Gem Is Not Loaded
Ignoring Gem Because Its Extensions Are Not Built
How to Use Gem to Install Rails on Ubuntu
Find Key/Value Pairs Deep Inside a Hash Containing an Arbitrary Number of Nested Hashes and Arrays