The component of the Ruby on Rails framework responsible for mapping between HTTP requests and application resources (including static files and controller actions).
Questions tagged [rails-routing]
969 questions
6
votes
1 answer
Rails 4 routing: using namespaces with dynamic segments
When discussing Routing using Dynamic Segments, the Ruby on Rails Guides (v4.0.1) say "You can't use :namespace or :module with a :controller path segment." They go on to suggest: "if you need to do this then use a constraint on :controller that…

RobJ
- 129
- 10
6
votes
3 answers
Rails routing: format constraints when none is specified
For Reasons™, I want to have one controller handle html requests and another handle json api requests.
I've got this in my routes:
scope module: :api, as: :api do
constraints format: :json do
resources :users
end
end
constraints format:…

Chris Keele
- 3,364
- 3
- 30
- 52
5
votes
1 answer
How to make Rails route to response for the font files (eot)?
In my rails(2.x) application. I want to use custom font in my view. So that I added the font files in public under fonts folder. When I try to get the fonts in url or via application, it through routing error. I guess rails routes not able to…

Jak
- 2,893
- 3
- 19
- 33
5
votes
2 answers
How to trigger different actions based on submit button in rails
I have a form with a list of stuff, and an action already in place to update items.
I want to have another button, which when clicked triggers a different action to remove the selected items.
= form_for @new_item,:url => {:controller =>…

Chris
- 6,076
- 11
- 48
- 62
5
votes
2 answers
Rails query string with a period (or full stop).
I am currently trying to get a handle on RoR. I am passing in two strings into my controller. One is a random hex string and the other is an email. The project is for a simple email verification on a database. The problem I am having is when I…

griffithben
- 115
- 9
5
votes
2 answers
Rails: RESTful resources: Worth using or inflexible/overrated?
I've been messing about in rails the past 2 months and so far everything's going well - but there's one area I'm a little doubtful on.
I keep hearing about the joys of RESTful rails resources: that is, a 'resource :foo' in config/routes, and your 7…

PlankTon
- 12,443
- 16
- 84
- 153
5
votes
1 answer
Can't create a route that has a segment with a leading dot in Rails (to verify Let's Encrypt)
In my Rails 5 app on Heroku, I'm trying to create a route for this URL: http://beta.example.com/.well-known/acme-challenge/some-key, so I can verify my server with Let's Encrypt to get an SSL certificate. But I can't get the route to work with a…

Patrick O'Grady
- 548
- 4
- 13
5
votes
1 answer
Rails 4: how to implement routes for a many-to-many relationship?
In our Rails 4 app, there are four models:
class User < ActiveRecord::Base
has_many :administrations, dependent: :destroy
has_many :calendars, through: :administrations
end
class Administration < ActiveRecord::Base
belongs_to :user
…

Thibaud Clement
- 6,607
- 10
- 50
- 103
5
votes
1 answer
can't get rails current_page? method to work with both GET and POST
Given I have the following routes defined in routes.rb
get "signup" => "users#new"
post "signup" => "users#create"
and the following condition in my erb view
<%if current_page?(login_path) or current_page?(signup_path)%>
NOW YOU'RE…

user3277633
- 1,891
- 6
- 28
- 48
5
votes
1 answer
How do I use Simple_Form with Nested Resources?
I have 3 models: FamilyTree, Node, Comment.
Every entry on a FamilyTree is a Node. A node can be a comment.
The models are as follows:
FamilyTree.rb
# == Schema Information
#
# Table name: family_trees
#
# id :integer not null,…

marcamillion
- 32,933
- 55
- 189
- 380
5
votes
2 answers
Routing Error in rails app 'uninitialized constant HomeController'
Im new to use foundation and i have created simple Posts app using scaffold
and i have done following steps:
rails new blog
then added following to Gemfile
gem 'foundation-rails'
group :development do
gem 'rails_layout'
end
and then
$ bundle…

PallavSharma
- 439
- 2
- 12
- 21
5
votes
1 answer
Exclude all other resources from subdomain in Rails
I have a Rails 4.0 app with that allows users to access blogs through subdomains. My routes currently look like this:
match '', to: 'blogs#show', via: [:get, :post], constraints: lambda { |r| r.subdomain.present? && r.subdomain != 'www' }
resources…

Yuval Karmi
- 26,277
- 39
- 124
- 175
5
votes
1 answer
Determine if Journey::Path::Pattern matches current page
I'm trying to use the method outlined this post in conjunction with url_for to determine if the current path is in a mounted engine, but I'm having a hard time figuring out how exactly to use Journey::Path::Pattern (which is what is returned by the…

Jonathan Bender
- 1,911
- 4
- 22
- 39
5
votes
1 answer
RSpec not finding my named routes
I'm having an inexplicably hard time getting my named routes to work within my rspec tests.
Here's what I'm seeing:
1) Home GET / works!
Failure/Error: get root_path
NameError:
undefined local variable or method `root_path' for…

isthmuses
- 1,316
- 1
- 17
- 27
5
votes
2 answers
How do I make config.exceptions_app work with rspec
In my Rails 3.2 app, I'm trying to use config.exceptions_app to route exceptions through the routing table to render error-specific pages (especially one for 401 Forbidden). Here's what I've got so far for configuration:
#…

7over21
- 299
- 2
- 9