How to implement remote form to another controller action in Rails 5 with no redirect?How do I call controller/view methods from the console in Rails?How to manage a redirect request after a jQuery Ajax callHow to prevent buttons from submitting formsHow can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?How to redirect to a 404 in Rails?Create new object without redirecting to new_xxx_path in railsHow to use concerns in Rails 4Need to redirect to another form after devise sign up formaction mailer for rails 4

Does the Rogue's Reliable Talent feature work for thieves' tools, since the rogue is proficient in them?

How to rename multiple files in a directory at the same time

Developers demotivated due to working on same project for more than 2 years

Given 0s on Assignments with suspected and dismissed cheating?

It is as easy as A B C, Figure out U V C from the given relationship

How to continually let my readers know what time it is in my story, in an organic way?

What color to choose as "danger" if the main color of my app is red

Why is Drogon so much better in battle than Rhaegal and Viserion?

Capital gains on stocks sold to take initial investment off the table

Windows 10 lock screen - display my own random images

Will there be more tax deductions if I put the house completely under my name, versus doing a joint ownership?

What do you call the hair or body hair you trim off your body?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview

c++ conditional uni-directional iterator

Why is the Advance Variation considered strong vs the Caro-Kann but not vs the Scandinavian?

Was the dragon prowess intentionally downplayed in S08E04?

How would you translate "grit" (personality trait) to Chinese?

What do the "optional" resistor and capacitor do in this circuit?

Were any of the books mentioned in this scene from the movie Hackers real?

Getting a similar picture (colours) on Manual Mode while using similar Auto Mode settings (T6 and 40D)

Why commonly or frequently used fonts sizes are even numbers like 10px, 12px, 16px, 24px, or 32px?

Network latencies between opposite ends of the Earth

What was Varys trying to do at the beginning of S08E05?



How to implement remote form to another controller action in Rails 5 with no redirect?


How do I call controller/view methods from the console in Rails?How to manage a redirect request after a jQuery Ajax callHow to prevent buttons from submitting formsHow can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?How to redirect to a 404 in Rails?Create new object without redirecting to new_xxx_path in railsHow to use concerns in Rails 4Need to redirect to another form after devise sign up formaction mailer for rails 4






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Trying to submit a form that has a create action in another controller but does not redirect to or render the page (just stay on the page).



Error:



MessagesController#create is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []


Form (rooms/show.html.haml):



 = form_for [@room, Message.new], remote: true do |f| 
.field
= f.text_field :body, placeholder: "Message #@room.name", autofocus: true


Remote Controller action:



class MessagesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_user!
before_action :set_room

def create
message = @room.messages.new(message_params)
message.user = current_user
message.save
MessageRelayJob.perform_later(message)
end

private

def set_room
@room = current_user.rooms.find(params[:room_id])
end

def message_params
params.require(:message).permit(:body)
end
end


messages/create.js.erb



$("#new_message")[0].reset();









share|improve this question
























  • It would be great if you write your own answer. Removing my answer as useless for your case

    – Vasilisa
    Apr 1 at 13:29

















0















Trying to submit a form that has a create action in another controller but does not redirect to or render the page (just stay on the page).



Error:



MessagesController#create is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []


Form (rooms/show.html.haml):



 = form_for [@room, Message.new], remote: true do |f| 
.field
= f.text_field :body, placeholder: "Message #@room.name", autofocus: true


Remote Controller action:



class MessagesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_user!
before_action :set_room

def create
message = @room.messages.new(message_params)
message.user = current_user
message.save
MessageRelayJob.perform_later(message)
end

private

def set_room
@room = current_user.rooms.find(params[:room_id])
end

def message_params
params.require(:message).permit(:body)
end
end


messages/create.js.erb



$("#new_message")[0].reset();









share|improve this question
























  • It would be great if you write your own answer. Removing my answer as useless for your case

    – Vasilisa
    Apr 1 at 13:29













0












0








0


0






Trying to submit a form that has a create action in another controller but does not redirect to or render the page (just stay on the page).



Error:



MessagesController#create is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []


Form (rooms/show.html.haml):



 = form_for [@room, Message.new], remote: true do |f| 
.field
= f.text_field :body, placeholder: "Message #@room.name", autofocus: true


Remote Controller action:



class MessagesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_user!
before_action :set_room

def create
message = @room.messages.new(message_params)
message.user = current_user
message.save
MessageRelayJob.perform_later(message)
end

private

def set_room
@room = current_user.rooms.find(params[:room_id])
end

def message_params
params.require(:message).permit(:body)
end
end


messages/create.js.erb



$("#new_message")[0].reset();









share|improve this question
















Trying to submit a form that has a create action in another controller but does not redirect to or render the page (just stay on the page).



Error:



MessagesController#create is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []


Form (rooms/show.html.haml):



 = form_for [@room, Message.new], remote: true do |f| 
.field
= f.text_field :body, placeholder: "Message #@room.name", autofocus: true


Remote Controller action:



class MessagesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authenticate_user!
before_action :set_room

def create
message = @room.messages.new(message_params)
message.user = current_user
message.save
MessageRelayJob.perform_later(message)
end

private

def set_room
@room = current_user.rooms.find(params[:room_id])
end

def message_params
params.require(:message).permit(:body)
end
end


messages/create.js.erb



$("#new_message")[0].reset();






ruby-on-rails ajax forms ruby-on-rails-5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 14:14







Brandon

















asked Mar 23 at 15:13









BrandonBrandon

12




12












  • It would be great if you write your own answer. Removing my answer as useless for your case

    – Vasilisa
    Apr 1 at 13:29

















  • It would be great if you write your own answer. Removing my answer as useless for your case

    – Vasilisa
    Apr 1 at 13:29
















It would be great if you write your own answer. Removing my answer as useless for your case

– Vasilisa
Apr 1 at 13:29





It would be great if you write your own answer. Removing my answer as useless for your case

– Vasilisa
Apr 1 at 13:29












0






active

oldest

votes












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/3.0/"u003ecc by-sa 3.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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315180%2fhow-to-implement-remote-form-to-another-controller-action-in-rails-5-with-no-red%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315180%2fhow-to-implement-remote-form-to-another-controller-action-in-rails-5-with-no-red%23new-answer', 'question_page');

);

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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript