All Questions
Tagged with routes ruby-on-rails
5,859
questions
0
votes
0
answers
42
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
41
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
82
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
69
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
50
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
64
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
57
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
60
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
27
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
82
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
83
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
48
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
93
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 ...
0
votes
1
answer
109
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
35
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 :...