How to create a custom create route in railsCan Rails Routing Helpers (i.e. mymodel_path(model)) be Used in Models?A concise explanation of nil v. empty v. blank in Ruby on RailsUnderstanding the Rails Authenticity TokenHow to write a switch statement in RubyHow can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?Rails layouts per action?Rails Restful Routing and SubdomainsHow to run `rails generate scaffold` when the model already exists?Best practices to handle routes for STI subclasses in rails
Vehicle routing benchmark instances
Going to France with limited French for a day
practicality of 30 year fix mortgage at 55 years of age
Fuel sender works when outside of tank, but not when in tank
How can this Stack Exchange site have an animated favicon?
Hilbert's hotel: why can't I repeat it infinitely many times?
Why does (inf + 0j)*1 evaluate to inf + nanj?
Concrete example of Vertex Cover to Subset Sum reduction
Comma Code - Automate the Boring Stuff with Python
Get Max value comparing multiple columns and return specific values
Can you cast Dispel Magic on a Shadow Monk's Silence?
What is the meaning of "heutig" in this sentence?
Can the U.S. president make military decisions without consulting anyone?
Is it impolite to ask for halal food when traveling to and in Thailand?
What benefits does the Power Word Kill spell have?
Why does this image of Jupiter look so strange?
On the meaning of 'anyways' in "What Exactly Is a Quartz Crystal, Anyways?"
Is it a good idea to leave minor world details to the reader's imagination?
How do pilots align the HUD with their eyeballs?
Can anyone put a name to this Circle of Fifths observation?
Proper way to shut down consumer
Could Apollo astronauts see city lights from the moon?
Is there any iPhone SE out there with 3D Touch?
Do I have advantage with Riposte when moving away from a flanked enemy and triggering an opportunity attack?
How to create a custom create route in rails
Can Rails Routing Helpers (i.e. mymodel_path(model)) be Used in Models?A concise explanation of nil v. empty v. blank in Ruby on RailsUnderstanding the Rails Authenticity TokenHow to write a switch statement in RubyHow can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?Rails layouts per action?Rails Restful Routing and SubdomainsHow to run `rails generate scaffold` when the model already exists?Best practices to handle routes for STI subclasses in rails
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I currently have a create method in an invoices controller. However i need another one, which is called 'create_inappointment_invoice'. I was wondering what the syntax was in the routes file to create a route in relation to this. I basically want the same route as this resources :invoices, controller: "admins/invoices", only: [:create] but changing the name of the controller action. Thanks
ruby-on-rails ruby routes
add a comment
|
I currently have a create method in an invoices controller. However i need another one, which is called 'create_inappointment_invoice'. I was wondering what the syntax was in the routes file to create a route in relation to this. I basically want the same route as this resources :invoices, controller: "admins/invoices", only: [:create] but changing the name of the controller action. Thanks
ruby-on-rails ruby routes
add a comment
|
I currently have a create method in an invoices controller. However i need another one, which is called 'create_inappointment_invoice'. I was wondering what the syntax was in the routes file to create a route in relation to this. I basically want the same route as this resources :invoices, controller: "admins/invoices", only: [:create] but changing the name of the controller action. Thanks
ruby-on-rails ruby routes
I currently have a create method in an invoices controller. However i need another one, which is called 'create_inappointment_invoice'. I was wondering what the syntax was in the routes file to create a route in relation to this. I basically want the same route as this resources :invoices, controller: "admins/invoices", only: [:create] but changing the name of the controller action. Thanks
ruby-on-rails ruby routes
ruby-on-rails ruby routes
asked Mar 28 at 17:29
b.herringb.herring
1449 bronze badges
1449 bronze badges
add a comment
|
add a comment
|
3 Answers
3
active
oldest
votes
post 'admins/all_invoices', to: 'admin#invoices'
where admin is your controller and invoices in your action in it.
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
If the above routeadmins/all_invoicesmatches then the control would go to your controlleradminand actioninvoicesFor Eg:class Admincontroller < ApplicationController def invoices # write your code here end end
– Srinidhi Gs
Mar 28 at 18:14
add a comment
|
Something like the below snippet should do the job:
resources :invoices, controller: "admins/invoices", only: [:create] do
collection do
post :create_inappointment_invoice
end
end
OR
resources :invoices, controller: "admins/invoices", only: [:create] do
post :create_inappointment_invoice, on: :collection
end
This will hit the create_inappointment_invoice method in your admin/invoices controller
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
it's currently hitting therender newpart of my other create action condition, which would suggest that it is still hitting the original create method.
– b.herring
Mar 29 at 8:39
add a comment
|
This seemed to work:
`post "/invoices", to: "admins/invoices#create_inappointment_invoice", as: :create_inappointment_invoice`
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403660%2fhow-to-create-a-custom-create-route-in-rails%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
post 'admins/all_invoices', to: 'admin#invoices'
where admin is your controller and invoices in your action in it.
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
If the above routeadmins/all_invoicesmatches then the control would go to your controlleradminand actioninvoicesFor Eg:class Admincontroller < ApplicationController def invoices # write your code here end end
– Srinidhi Gs
Mar 28 at 18:14
add a comment
|
post 'admins/all_invoices', to: 'admin#invoices'
where admin is your controller and invoices in your action in it.
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
If the above routeadmins/all_invoicesmatches then the control would go to your controlleradminand actioninvoicesFor Eg:class Admincontroller < ApplicationController def invoices # write your code here end end
– Srinidhi Gs
Mar 28 at 18:14
add a comment
|
post 'admins/all_invoices', to: 'admin#invoices'
where admin is your controller and invoices in your action in it.
post 'admins/all_invoices', to: 'admin#invoices'
where admin is your controller and invoices in your action in it.
answered Mar 28 at 17:33
Srinidhi GsSrinidhi Gs
604 bronze badges
604 bronze badges
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
If the above routeadmins/all_invoicesmatches then the control would go to your controlleradminand actioninvoicesFor Eg:class Admincontroller < ApplicationController def invoices # write your code here end end
– Srinidhi Gs
Mar 28 at 18:14
add a comment
|
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
If the above routeadmins/all_invoicesmatches then the control would go to your controlleradminand actioninvoicesFor Eg:class Admincontroller < ApplicationController def invoices # write your code here end end
– Srinidhi Gs
Mar 28 at 18:14
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
thanks for your answer, however i dont quite understand your description.
– b.herring
Mar 28 at 17:46
If the above route
admins/all_invoices matches then the control would go to your controller admin and action invoices For Eg: class Admincontroller < ApplicationController def invoices # write your code here end end– Srinidhi Gs
Mar 28 at 18:14
If the above route
admins/all_invoices matches then the control would go to your controller admin and action invoices For Eg: class Admincontroller < ApplicationController def invoices # write your code here end end– Srinidhi Gs
Mar 28 at 18:14
add a comment
|
Something like the below snippet should do the job:
resources :invoices, controller: "admins/invoices", only: [:create] do
collection do
post :create_inappointment_invoice
end
end
OR
resources :invoices, controller: "admins/invoices", only: [:create] do
post :create_inappointment_invoice, on: :collection
end
This will hit the create_inappointment_invoice method in your admin/invoices controller
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
it's currently hitting therender newpart of my other create action condition, which would suggest that it is still hitting the original create method.
– b.herring
Mar 29 at 8:39
add a comment
|
Something like the below snippet should do the job:
resources :invoices, controller: "admins/invoices", only: [:create] do
collection do
post :create_inappointment_invoice
end
end
OR
resources :invoices, controller: "admins/invoices", only: [:create] do
post :create_inappointment_invoice, on: :collection
end
This will hit the create_inappointment_invoice method in your admin/invoices controller
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
it's currently hitting therender newpart of my other create action condition, which would suggest that it is still hitting the original create method.
– b.herring
Mar 29 at 8:39
add a comment
|
Something like the below snippet should do the job:
resources :invoices, controller: "admins/invoices", only: [:create] do
collection do
post :create_inappointment_invoice
end
end
OR
resources :invoices, controller: "admins/invoices", only: [:create] do
post :create_inappointment_invoice, on: :collection
end
This will hit the create_inappointment_invoice method in your admin/invoices controller
Something like the below snippet should do the job:
resources :invoices, controller: "admins/invoices", only: [:create] do
collection do
post :create_inappointment_invoice
end
end
OR
resources :invoices, controller: "admins/invoices", only: [:create] do
post :create_inappointment_invoice, on: :collection
end
This will hit the create_inappointment_invoice method in your admin/invoices controller
answered Mar 28 at 17:39
AbhishekAbhishek
1115 bronze badges
1115 bronze badges
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
it's currently hitting therender newpart of my other create action condition, which would suggest that it is still hitting the original create method.
– b.herring
Mar 29 at 8:39
add a comment
|
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
it's currently hitting therender newpart of my other create action condition, which would suggest that it is still hitting the original create method.
– b.herring
Mar 29 at 8:39
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
Thanks for your answer. However, this is taking me to the original create method still.
– b.herring
Mar 28 at 17:45
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
It shouldn't be! What's the url you are hitting?
– Abhishek
Mar 28 at 17:48
it's currently hitting the
render new part of my other create action condition, which would suggest that it is still hitting the original create method.– b.herring
Mar 29 at 8:39
it's currently hitting the
render new part of my other create action condition, which would suggest that it is still hitting the original create method.– b.herring
Mar 29 at 8:39
add a comment
|
This seemed to work:
`post "/invoices", to: "admins/invoices#create_inappointment_invoice", as: :create_inappointment_invoice`
add a comment
|
This seemed to work:
`post "/invoices", to: "admins/invoices#create_inappointment_invoice", as: :create_inappointment_invoice`
add a comment
|
This seemed to work:
`post "/invoices", to: "admins/invoices#create_inappointment_invoice", as: :create_inappointment_invoice`
This seemed to work:
`post "/invoices", to: "admins/invoices#create_inappointment_invoice", as: :create_inappointment_invoice`
answered Mar 29 at 9:25
b.herringb.herring
1449 bronze badges
1449 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403660%2fhow-to-create-a-custom-create-route-in-rails%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown