All Questions
Tagged with routes ruby-on-rails
5,865 questions
-1
votes
1
answer
49
views
Routes are not getting available using resources in Rails
I am trying to learning Ruby On Rails MVC framework by implementing a test application where I am trying to create form submission and listing records. I am using resources way to define my routes to ...
-1
votes
2
answers
77
views
No route matches Error in Controller and Router using Ruby on Rails MVC
I am new to ruby on rails. And I am trying to test one simple record pull example using Active Record. I am getting the following error while giving action from router to controller to get some ...
0
votes
0
answers
40
views
Dynamic Routes in Rails [duplicate]
I have a Help File system that is quite lengthy. It will be governed by its own controller-model-view that will show the various help pages as the user clicks on the corresponding link. The client ...
0
votes
1
answer
71
views
Why redirect in the routes file?
Reading the Ruby on Rails guide, I see this example:
get '/stories/:name', to: redirect('/articles/%{name}')
And I'm confused, when would this be helpful? Couldn't you just point the path to the ...
1
vote
1
answer
85
views
Rails route path helpers from inside namespaced controller
I have an app with a few top level models, all working. My layout views have a header partial, and this has the main nav links on a navbar, pretty standard stuff. Now I come to add some new ...
0
votes
0
answers
52
views
Rails multidomain project, it shows only Welcome page, other routes show routing error
I have a project with multiple subdomains for companies. When I access the project in production, it first shows the welcome page of the project, which has a login button that I can use to log in. ...
0
votes
0
answers
47
views
what is the better way to add conditional routing in rails
I have to change the route in a way that I need to have the original route as well as change the path of the route in a env is available.
this is how I am thinking of doing
custom_org = ENV['...
0
votes
1
answer
51
views
Rails Routing - 'api/v1/sessions' is not a supported controller name [closed]
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :users, only: [:create, :show, :index]
post '/login', to: 'sessions:#create'
delete '/logout', to:...
1
vote
1
answer
92
views
form_with is trying to generate the action with the wrong path
I'm experimenting with routing and namespaces.
When implementing a form with <%= form_with model: [@user, @address] do |form| %>
i receive this error undefined method '...
1
vote
3
answers
80
views
Rails routing: organizing routes under a namespace having its own route
The general goal is to organize some routes under a /configuration/* path mapped to a Configurations:: controller's namespace. For example, /configuration/teams mapped to Configurations::...
1
vote
1
answer
64
views
Rails engine: export two sets of routes
I have a Rails engine MyGreatEngine defined in a gem mge. This engine provides two types of routes, one related to APIs and one related to static files.
I would like to export two sets of routes, one ...
0
votes
1
answer
90
views
Route path with parameters breaks in Rails 7
I'm upgrading an existing Rails 5 application to Rails 7 and am having problems with paths used in link_to().
For example: in my routes.rb I have the following declaration for recording_sets:
...
0
votes
1
answer
66
views
What HTTP method should a route have if it's for create_or_delete
Yea I know it's such a strange purpose create_or_delete. But I have an attendances table for users, and in the frontend there's a checkbox,
when it's checked -> create an attendance record
when ...
0
votes
1
answer
65
views
When I fetch an object from Rails and print it out in the terminal, it returns its ID, but not when converted to JSON. Any clue why?
Here's the relevant code.
This is a custom method I'm using.
/app/controllers/prep_sheets_controller.rb
def create_back_right
@back_sheet = PrepSheet.new().new_back_right
puts '--------------...
0
votes
1
answer
34
views
Rails create/destroy association for existing models by JSON call
I have two models that I want to manually associate or dissociate on demand.
class Car < ApplicationRecord
has_many :wheels, dependent: :nullify
end
class Wheel < ApplicationRecord
...
1
vote
2
answers
87
views
How to control or customise named route Rails's link_to() uses for a model?
I have a namespaced model and controller:
# app/controllers/foo_stuff/bars_controller.rb
module FooStuff
class BarsController < ApplicationController
# ..
end
end
# app/models/foo_stuff/...
0
votes
0
answers
134
views
How do I redirect_to a route thats inside of a namespace in rails?
I have a project where I am using rails as my backend and I have a model called "Projects". I am trying to do a simple redirect to my index action after deleting a single project but I keep ...
0
votes
1
answer
52
views
Routing to root path for differents domains on the same server
I'm trying to create a multi tenant on rails app.
How can I do to define the root path for each domain ?
I tried several solutions, but still have the same error :
ActionController::RoutingError (No ...
1
vote
2
answers
103
views
Changing underscores to hyphens in URLs Ruby on Rails
I need to change underscores to hyphens for SEO of our to-do checklist page in Ruby on Rails project. The relevant line in routes.rb file is below:
get 'to_do' => 'current_to_do_items#landing', :as ...
1
vote
1
answer
154
views
Rails 7 won't generate a destroy path for the comment deletion [closed]
I'm trying to make a delete helper for a comment, this is the html code :
<% if store_comment.user_id == current_user.id %>
<%= link_to 'edit', edit_store_post_store_comment_path(params[:...
1
vote
1
answer
37
views
Why there are no namespace routes generated?
I am stuck with the following code, trying to create a namespace route.
Rails.application.routes.draw do
# skipping some lines for clarity
devise_for :users
authenticate :user do
resources :...
0
votes
1
answer
70
views
Nextjs routing without prefixes Spree Commerce
I'm new to Next.js, and I want to replicate the permalink structure from a WordPress/WPML/Woocommerce site that has English as the default language (no "en" prefix) and additional languages: ...
2
votes
1
answer
211
views
How do I handle client side routes, when a page refresh returns the backend rails' route instead?
I have deployed my SPA to Render. It consists of a React with Redux frontend, and a Rails backend. When the app mounts, it renders the correct frontend route in the browser, and any subsequent ...
1
vote
1
answer
67
views
Rails URL helpers and `delegated_type`
Let's say I have setup like the delegated_type docs:
class Entry < ApplicationRecord
belongs_to :account
belongs_to :creator
delegated_type :entryable, types: %w[ Message Comment ]
end
...
2
votes
2
answers
118
views
Rails post delete path is assigned to GET method instead of DELETE
After I associated the comments & the posts, the post_delete_path started sending a GET request instead of a Delete one when called, showing the following error :
<No route matches [DELETE] &...
1
vote
1
answer
155
views
An accepted way to get Current.user in routes.rb
I have a number of Rails engines in a Rails app, and each currently has its own constraint class to determine whether to allow the user
mount Flipper::UI.app(Flipper) => '/admin/flipper', :as => ...
1
vote
0
answers
30
views
Getting routes error in test helper for simulation a session
I have been trying to enforce permissions that admin should only create articles. I am writing the tests on minitest. The thing is that I have created the user in categories controller test file and ...
1
vote
1
answer
23
views
Reference custom resource path from the view
I would like to call a custom controller method "load" from the view. I am struggling to understand how I should call the path to call in the view. In my routes.rb I have the following code:
...
1
vote
1
answer
127
views
Ruby on Rails: sign out isn't working for devise with User
I have the following routes:
I'm developing an exercise tracking app and I want to have tracked_exercises for the currently logged in user. This is my routes.rb file:
Rails.application.routes.draw do
...
0
votes
0
answers
42
views
I try to open users/new but I get routing error
I am a programmer who is just starting out, but I don't know how to fix this error since I don't see any flaws in it
I need help to continue with the project
Routes
Rails.application.routes.draw do
...
1
vote
1
answer
13
views
Custom Routes: How does one properly add the id inside a custom route with redirection in Ruby/Rails?
I have a custom route and I need to add the id inside the redirect call inside of the "to:" key-value pair. I've tried regular way:
# My Cars
get '/api/cars/profile/:car_id', to: redirect('/...
0
votes
1
answer
358
views
Ruby on Rails responds "no route matches" for all routes while rack routes command shows them as expected
Situation
I'm absolutly new to Ruby but somewhat experienced with Django, Node and other technologies.
I'm trying to run a legacy project from my employer on my local, which is actually running in ...
1
vote
2
answers
216
views
Namespaced constraint classes not found in routes after upgrade to Rails 7
I've been using constraint classes in my routes.rb forever, like so:
get '/auth/:provider/callback', to: "oauth_accounts#create_or_update", constraints: Constraints::...
1
vote
2
answers
108
views
double rendering after super is called in devise
class CustomSessionsController < DeviseTokenAuth::SessionsController
def create
binding.pry
super
confirmed = true
binding.pry
if current_user.present? && confirmed
...
0
votes
0
answers
50
views
Rails nested ressources - missing required keys: [:entry_id]
I have two models:
class Credit < ApplicationRecord
belongs_to :user
has_many :entries, -> { order(position: :asc) }, dependent: :destroy
end
class Entry < ...
0
votes
2
answers
154
views
Add a static Thank You page on form submit using Rails
New to Rails but having difficulty getting this thank you page to load.
Problem: A website visitor can fill out the contact us form on my site, then get routed to a generic Thank You page. However, ...
3
votes
2
answers
735
views
How to find rails route pattern from url
Given a rack request where I know the path, e.g. /things/1, how can I get the route reference e.g. /things/:id?
I can use Rails.application.routes.recognize_path to get the controller and action, but ...
0
votes
1
answer
15
views
Rails redirects route even though logically it doesn't make sense
I have the following controller
class DashboardController < ApplicationController
before_action :authenticate_user!, except: [:show]
before_action :set_user, only: [:show]
def index
@...
1
vote
0
answers
24
views
The browser sends the data, but does not changing the page at the address /articles
I write form_with on /new page, when I press the button browser send data(I see it by server and fiddler),but the /new page not redirecting by /articles address.
I try to restart server and another ...
1
vote
0
answers
60
views
Pathless `url_for` and controllers with multiple resource routes
It's possible to use link_to and associated helpers without specifying a URL, path, or route helper; in that case Rails, will generate a URL based on the current view:
# app/views/files/index.html.erb
...
0
votes
0
answers
23
views
Post request transfered to get in Rails
I have a 2 routes for posts:
resources :posts, only: %i[show] do
collection do
post 'bulk_delete'
end
end
Somehow in my tests, execution ends up in show route even if I execute bulk_delete ...
0
votes
3
answers
78
views
Error when deleting microposts. For some reason the GET method is requested for https
Please understand that I am not familiar with English.
I am creating a sample application with Rails.
For some reason the following error occurs when I press the delete button on a micropost.
error
...
0
votes
1
answer
71
views
No route matches [GET] "/order_items" when adding an item to shopping cart
Whenever I try to add an article to the shopping cart from the item's show page I've been getting the following routing error: ActionController::RoutingError (No route matches [GET] "/order_items&...
0
votes
1
answer
89
views
Ruby on Rails - Duplicate routes & impact on controllers
I am creating a Task Manager.
So, I have:
A dashboard where I can do CRUD for tasks (and then I will assign them a group)
A group section where I can go inside a group and do CRUD for tasks
Then my ...
0
votes
2
answers
70
views
add dynamic route from rails database model?
How can I add dynamic route from database, using model activeRecord :
I try : (using Rails 5)
Rails.application.routes.draw do
router = self
Var.find_by(name: 'pages').value.split(',').each do |...
0
votes
2
answers
103
views
Invalid route name, already in use: 'root'
I get:
Invalid route name, already in use: 'root'
You may have defined two routes with the same name using the :as option, or you may be overriding a route already defined by a resource with the same ...
0
votes
0
answers
34
views
How can I redirect website.com/en to website.com/en/ in Rails?
We have this in routes.rb for localization:
scope "/:locale", locale: /#{I18n.available_locales.join("|")}/, defaults: {locale: 'nl'} do
get '/', to: 'home_student#index'
...
0
votes
0
answers
28
views
Can't read local geojson
Trying to read a geojson in Rail. Specifically
/public/switzerland.geojson
Console error:
Started GET "/oladvancedview" for ::1 at 2023-02-02 16:42:44 -0800
Processing by DemoController#...
0
votes
1
answer
185
views
How to add the name of a blog post's category to route url with Rails 7
I have been trying to add the name of the BlogCategory that a BlogPost belongs to in a URL such as this:
sitename.com/blog/category-name/blog-post-title
At the very least, I want this to render for ...
0
votes
2
answers
59
views
Route perform wrong action on submit form_with [closed]
i'm having trouble with my rails aplication.
i have a form who should submit some fields to be search to /cities/search/<params_here>.
but, when i submit form, the routing goes to wrong action, ...