I’m using Rails 4.2.3. I want to submit a form in a modal dialog, so I have set up my form like so
<%= form_for @my_object, :remote => true do |f| %>
If you have want to redirect it after successfully create/updated
and just use .html
method. Otherwise just use JS option like in this LINK.
def create
@my_object = MyObject.new(my_object_params.merge(user: User.find(session["user_id"])))
respond_to do |format|
if @my_object.save
format.html { redirect_to controller: "users", action: "index", notice: 'Saved successfully.' }
else
....
end
end
end