Yes, you can. If you have the respond_to block in the controller, then anything
you put inside the block can do whatever it wants to. Here's one from a
controller I made some time ago with the scaffold generator:
def update
respond_to do |format|
if @country.update(country_params)
format.html { redirect_to @country, notice: 'Country was successfully
updated.' }
format.json { render :show, status: :ok, location: @country }
else
format.html { render :edit }
format.json { render json: @country.errors, status:
:unprocessable_entity }
end
end
end
Only one block will respond to the action here, depending on the format and the
result of #update. So this won't violate the single render/redirect constraint
on controller method.
At the Ruby level, this is just a block inside a block.
Walter
> On Sep 8, 2018, at 10:58 AM, fugee ohu <[email protected]> wrote:
>
> I wanna modify the dom on the coversations show page which contains a new
> message form for the messages controller Presently the create action in the
> messages controlller redirects to conversations/show I wanna respond js with
> simply render conversations/show Can I do that?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/efcc9162-a8f3-4d9c-98ff-690dfc04530f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/A8EA7881-97A2-413F-8256-54733B04CC8C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.