The ActionDispatch
namespace module within the Ruby on Rails web framework.
Questions tagged [actiondispatch]
84 questions
2
votes
1 answer
Rails with custom error through routes - read original requested URL
I am using a custom error controller. I would like to have a 200 response code when visiting the 500 page URL (otherwise my middleware that intercepts 500 response codes sends me an exception email whenever I want to show off my 500)
It would seem…

Cyril Duchon-Doris
- 12,964
- 9
- 77
- 164
2
votes
0 answers
Override Rails Routing resources method create extra RESTful actions
In the routes.rb :
namespace :admin, :format => false do
resources :activities
resources :categories
resources :charities
end
Add in all map.resources extra RESTful actions csv_export:
Create initilizer/mapper.rb file and add…

Kaushlendra Tomar
- 1,410
- 10
- 16
2
votes
2 answers
Carrierwave: NoMethodError - undefined method `permit' for #
I think I know the answer here already but I figured I would post this to help someone else that comes across this as I can't find this posted anywhere else.
I have a typical Rails model and added a Carrierwave uploader.
When I upload I get this…

Dan Tappin
- 2,692
- 3
- 37
- 77
2
votes
1 answer
How do I get the route for a path, in a rails application?
Given a method and path, I want to ask Rails how that request would be routed, and i want to be able to do this from console, and/or from a rake task. I figure this should be straightforward - ActionDispatch does this for every request, and the…

Evan
- 121
- 1
- 7
2
votes
2 answers
Forwarding unmanipulated multipart HTTP requests with Rails
Alright, this is going to be a little difficult to explain, so please bear with me...
I have a Rails app that encompasses a large javascript codebase written for the ESRI ArcGIS javascript API to interact with spatial data stored on an ESRI ArcGIS…

Ryan
- 113
- 1
- 10
2
votes
0 answers
how do I convert a path string to controller + action + parameters?
(I'm sure I've seen the answer to this, but can't find it after many minutes of digging. It should be an easy one to answer...)
motivation
In the console, you can invoke the get method with a path argument, such as:
app.get posts_path(321)
This…

fearless_fool
- 33,645
- 23
- 135
- 217
2
votes
1 answer
How can I control max-age for particular files with Rails?
I have Rails serving my static assets. Most of them have hashes in their name and are served with far-future expiration dates. But for one file, I can't serve it with a hash in its name, so I need to control the expiration date.
I have this in my…

John Bachir
- 22,495
- 29
- 154
- 227
1
vote
1 answer
Include Module into ruby class in a Rails initializer
Inside of an initializer in Rails i am trying to include a module in a rails Model
User.send :include, Something
This works for the first request but does not for the second/third/etc. due to rails model reloading. I tried using…

Schneems
- 14,918
- 9
- 57
- 84
1
vote
1 answer
How do you set the server port in Rails system tests?
The Rails server starts on a different port every time you run the system tests.
Is there any way to specify which port this should be and not have it change on every run?
I would like to test clicking a link from an ActionMailer message in my…

ayushn21
- 305
- 2
- 7
1
vote
1 answer
how to use contents of in Rails?
I've uploaded and encrypted two images to my app, and now I need to use them in an img_tag. How can I retrieve the contents of this string and display them to the user?
Model.document_front:

calyxofheld
- 1,538
- 3
- 24
- 62
1
vote
1 answer
ActionController::UrlGenerationError: No route matches and missing id even though I am passing the id to the test
I'm still new to rails and trying to write some basic tests for one of my controllers.
For the sake of keeping this question brief, let's look at two of my tests.
should show captable fails
should get index asserts successfully
From the error…

rock_n_rolla
- 337
- 4
- 13
1
vote
1 answer
Dispatch Rails Controller Action Outside of HTTP context (not in a unit test)
I maintain a mature codebase that uses Rails as an API. The Rails app also does some things with MQTT, a realtime, non-web, non-HTTP protocol.
Some users have requested the ability to simulate the same REST commands over the MQTT protocol (avoids…

Rick
- 8,366
- 8
- 47
- 76
1
vote
1 answer
Given a URL path, can I get the url params that would be used to fulfill the request?
For example in routes.rb I have something like
namespace :api do
namespace :v1 do
post 'login/:email' => 'authentication#login', email: /[^\/]+/
end
end
Given the string "/api/v1/login/lisa@example.com" I would like to know that…

galiat
- 54
- 1
- 4
1
vote
2 answers
ActionDispatch::IntegrationTest suppresses exceptions
When debugging failing integration tests, I keep running into the same problem where the exceptions raised in my code are suppressed and not shown in the testing output.
For example, for the following controller and test:
class…

Simon
- 322
- 1
- 13
1
vote
1 answer
Rspec to upload file with params
I'm trying to write spec for testing upload function and the code implementation works as expected however when I tried to write spec I'm not able to figure out why the data conversation is failing during JSON.parse. [ Rails 5.X ]
Method
def upload
…

Mad-D
- 4,479
- 18
- 52
- 93