969
questions
1
vote
1
answer
58
views
Unable to match custom method REST routes to ruby on rails
I am new to ruby-on-rails and having a hard time trying to get routes to match for my API service.
I designed my custom routes for resources following the Google AIP-136.
For example, for the ...
0
votes
0
answers
44
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
0
answers
29
views
Rails 5.2 routes with nested dynamic segment not working
I've upgrade rails from 5.1.6 to 5.2.8 and it have a problem with Routing using nested Dynamic Segments.
Rails.application.routes.draw do
scope "(:locale)", locale: /en|de/ do
scope &...
0
votes
0
answers
103
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
2
answers
268
views
how to go to logout path in rails?
I am using rails 7 and When I click on logout it show an error that logout path is not found.
Here is my code of routes.rb, session controller and header section for logout:
Rails.application.routes....
0
votes
2
answers
91
views
How do i solve friendly id issue in active admin
I am using Rails 7 Active admin
I have Project that is Workshop Project that is related to organizing workshops, booking them etc.
I am using Friendly ID Gem . The url looks like http://127.0.0.1:3000/...
2
votes
1
answer
55
views
API Rails routes where token is part of the route
I need to create a Ruby on Rails API where routes will look like
mydomain.com/api/v1/xxxxxxxx/
mydomain.com/api/v1/xxxxxxxx/messages
mydomain.com/api/v1/xxxxxxxx/authors/123/books
xxxxxxxx ...
0
votes
0
answers
38
views
update record by ajax
I am showing a view where I show several records and I have a checkbox that I would like that when I change its value is sent via ajax the request to update the record, so far it works fine and ...
0
votes
2
answers
117
views
Rails routing bug in "redirect_to" and "notice" flash message
I need to show notice/pop ups upon hitting of a button. Similar approaches are working in other views and controllers of the app but here on this Import button things are not working since long. None ...
0
votes
2
answers
53
views
NoMethodError | nested routes path problem in rails 6
I haven't been able to solve the error for a couple of days because of the nested path, what is the problem?
I realize that there is no such nested path as Rails is looking for, but why is he looking ...
1
vote
0
answers
114
views
Add custom routes to devise returns 404 ActionNotFound
I would like to create a new routes and method inside my Sessions Controller within Devise. I am using devise_token_auth
Here is my original routes.rb for devise :
namespace :api do
namespace :v1 ...
1
vote
1
answer
107
views
Automatically generating scoped and unscoped Rails routes
We have a tenant-like application that specifies many tenant and general routes for the same controller/action. As an example:
get '/:subdomain/posts', to: 'posts#index'
get '/posts', to: 'posts#index'...
0
votes
1
answer
124
views
Rails Wicked Gem - Odd Routing Issue
I have been banging my head against the wall all day today with this problem. I am building an onboarding wizard where I collect business information. It's many steps, but for this I will post simply ...
1
vote
2
answers
599
views
Rails - Clean way to mix nested+non-nested or member routes?
New to programming in general and Rails specifically.
TLDR:
Is there a clean way of using a variety of member actions or controlling flow in controllers for nested resources? Is there a third option? ...
0
votes
0
answers
417
views
How to resolve NoMethodError: undefined method `glob?' for nil:NilClass in Rails 7
I'm using ruby 3.1.0p0 and Rails 7.0.1. I recently upgraded from Rails 6.1 and ruby 2.7.
When I host the site locally I don't encounter any issues. But when I deploy the site to a Ubuntu 20.04 server ...
1
vote
1
answer
200
views
Rails route optional segments mapping issue
I originally had a route defined like this :
get ':foo(/:bar)/:baz(/:qux)/:slug', to: 'application#show', constraints: { baz: /.+?\-\d+/ }, as: test
With this configuration, it works fine if I omit :...
0
votes
1
answer
64
views
How do I transfer Data using Web Server/TCPsockets in Ruby?
I have a data scraper in ruby that retrieves article data.
Another dev on my team needs my scraper to spin up a webServer he can make a request to so that he may import the data on a Node Application ...
0
votes
1
answer
218
views
Domain specific routing with different paths per domain for same model
I have a Consultant model, where i have multiple consultant types (lawyers, doctors, psychologists etc.) listed on different websites, all handled from the same rails project.
I would like to have the ...
0
votes
1
answer
168
views
Rails routes with specific character
I have bellow url request type, that contain # character
http://localhost:3000#user-name
I want to match it to HomeController#show_user, how to write the routes?
0
votes
1
answer
123
views
How to use named routes when using FriendlyId at the root path in Rails
I have a basic Page model in Rails that I'm using with FriendlyId to allow admins to create pages like "/about" or "/contact".
I have the following in my routes file (config/routes....
1
vote
2
answers
356
views
I want to delete individual image in my albums controller in which I am inserting multiple images. How can I delete?
I have set up the authentication using devise user, and in that I am having my albums controller in which i am inserting multiple images. So far I have just created a method for deletion of image in ...
0
votes
0
answers
50
views
Rails routing to nested controller
I have one controller for creating category, and I want to have one more nested controller to create language versions of categories. I want to avoid methods like new_language, edit_language, ... and ...
0
votes
0
answers
259
views
How to explicitly declare routes for assets?
I have an app where the routes are:
# many routes go here
# last item in routes.rb:
get ':username' => 'users#show'
This allows routes of the form www.example.com/your_username
This works ...
0
votes
1
answer
292
views
How to declare a deep nested resource in activeadmin?
I have three resources in ActiveAdmin i.e User, Order, and OrderItems.
User => has_many :orders
User => has_many :order_items, through: :orders
I want OrderItems to be nested inside Users so I ...
0
votes
1
answer
149
views
rails dynamic route with pagination
I have the following routes:
Brand.all.each do |brand|
get "/#{brand.slug}", to: 'brands#index'#
end
That generates:
"/tommy"
"/lacoste"
"/gap"
But when I ...
0
votes
1
answer
149
views
Creating a prefix route in rails
I want to create URLs of the form /suffix-<slug> with rails but I can't see how to map that on the routes.rb, how can I do that?
0
votes
1
answer
546
views
dynamically intercept and recall Ruby on Rails Routes in Rails Engine
I am currently working on a Rails engine that will duplicate the host app's routings under a certain scope. So if a route get '/posts', to: 'posts#index', as: 'posts' exists in the original ...
0
votes
1
answer
36
views
Route with a query string is passed to incorrect controller action
With my rails api. At the moment if I do a get request to /seasons/2 I correctly have a json returned with the season table item of id= 2 through the Seasons controller show action.
But when I hit a ...
0
votes
1
answer
138
views
current_page? doesn't work for POST even using url_for()
current_page? doesn't work with POST requests, but there is said to be a solution here.
I try using url_for like so:
current_page?(url_for(controller: 'pages', action: 'booking_confirm'))
# but..
...
2
votes
1
answer
734
views
uninitialized constant ActionController::RedirectBackError Did you mean? ActionController::RenderError
Trying to implement redirect_to :back method
but I'm getting this error:
uninitialized constant ActionController::RedirectBackError Did you mean? ActionController::RenderError
my posts_controller.rb
...
0
votes
1
answer
469
views
Rails 6 - Issue with nested resources in a namespace
So I am trying to nest resources under a namespace, however when i try to navigate to the UserProfile new page I am hitting the following error:
ActionController::RoutingError at /users/xxxxxx/...
1
vote
2
answers
341
views
How to avoid ordinal, integer routes (incremental ids) in rails 'show' routes?
The simplest MRE is rails g scaffold users
As we create users, their id will be 1, 2, 3, 4 etc, and their 'show' route will be /show/:id
Sometimes we don't want users of the website to know exactly ...
0
votes
1
answer
40
views
How can i route a mothod for more than one controller rails 6
i have this in my routes.rb
get "invoices/log_out" => "users#logout", :as => "log_out"
this seems to work only in localhost:3000/invoices/new/log_out
as when i ...
0
votes
0
answers
358
views
Routing error upon overriding registrations controller in Rails API using devise token auth
I am trying to send a POST request (using Postman) to sign up a new user using devise token auth and I am overriding the registrations controller to enable my own JSON responses.
I keep getting a ...
0
votes
1
answer
373
views
Rails Route? How To Rename URL in Routes
I would like to rename my categories URL from https://website.com/categories/apples (#1) to
https://website.com/hi-apples-bye (#2)
I am trying to accomplish two things:
Display the #2 URL in the ...
0
votes
1
answer
961
views
rails URL rewriting using
How to rewrite below URL
127.0.0.1:3000/article/index?type=1
as
127.0.0.1:3000/article/category/brand
where type 1 is category with name brand.
is it possible using rails?
route.rb
get "article/...
0
votes
2
answers
2k
views
ActionController::RoutingError (No route matches [POST] "/users")
I've tested my project with development env and everything works fine but after I upload my project to the host I got this error.
# log
[2020-02-17T14:54:55.319109 #2097106] INFO -- : [2ac848c8-15f3-...
0
votes
1
answer
96
views
Devise scoped member routes issue
I'm using devise for sign up and ActiveStorage for image upload. For the delete/purge function to work I have this route
devise_scope :user do
scope module: :users do
resources :...
0
votes
0
answers
146
views
Rails route does not hit unsubscribe controller action
I followed these instructions, but now I'm running into a problem. When I click my unsubscribe_url in the email, I get the following error:
No route matches [GET] "/newsletter_subscriptions/...
1
vote
1
answer
3k
views
Rails ActiveStorage rails_blob_path generating invalid url with missing /rails in start
I am on:
Rails: 6.0.1
Ruby: 2.6.5
And I am using Rails.application.routes.url_helpers.rails_blob_path helper in one of my serializers to generate path to a pdf file. And it has been working great in ...
0
votes
2
answers
15
views
Creating routes with passing parametr
I need to create a rout, which url will look like this: www.sitename.com/action_name/[:id]
Write it as follows:
get '/how-to-transfer-colleges/:id', to:'seo_pages#how_to_transfer_colleges'
get '/how-...
3
votes
2
answers
4k
views
Rails form with url based on input
I feel like there's no easy way to do this in rails, but since I'm fairly noob in rails I decided to ask for solutions:
I have a form in a view that contains a single (text) input. How can I specify ...
-1
votes
1
answer
93
views
How can I route to a belongs_to table in Rails (using PostgreSQL)?
My relationship is as follows:
Users have many Cartitems; Cartitems belong to Users,
Cartitems have many Products; Products belong to Cartitems
Therefore, Users have many Products through Cartitems ...
0
votes
2
answers
330
views
How do I set up my Rails routes for a belongs-to relationship?
So I've got a simple database for an online retail store with a relationship of Users who have many Products through Cartproducts
Users have many cartproducts and have many products through ...
3
votes
3
answers
763
views
How to conditionally include route parameter in Rails?
I'm trying to allow for one resource, Site, to conditionally have a parent resource, Organization.
Here's what I currently have:
resources :site do
resources :posts do
resources :comments
...
0
votes
1
answer
148
views
Route translate the namespace route of a rails engine
I have a rails engine which is mounted on my application as
mount Engine::Engine, at: "/engine"
Is it possible to translate the namespace /engine so that in English it is /engine and in another ...
0
votes
3
answers
573
views
Rails naming convention for an action that shows a form and the other that processes the form
I need to create two routes. The first one is a GET route that shows a certain form, and the other is a POST route that processes the form.
For example, I need to create a route that shows a form ...
0
votes
1
answer
228
views
How to pass a symbol through rails routes specified through 'resources'?
I have this set of routes
resources :flatfiles do
collection do
delete :custom_destroy
end
end
And I would like to all of the routes to include :key
E.g. get 'flatfiles/:key' =&...
1
vote
1
answer
278
views
rails url_helper placing params where format should be
I'm trying to get Rails generated _path methods to give me
/terms_and_conditions?utm_source=source&utm_campaign=pain#some_link
So I've tried the following in a controller:
utm_params = {"...
1
vote
2
answers
209
views
How to send a variable from an action without using the URL in Rails?
How to send a variable/parameter from an action without using the URL?
I need to create a user in multiple steps, and the user is created on the 2nd step. I need to receive the email of the user from ...