Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 937045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:24:41+00:00 2026-05-15T21:24:41+00:00

I was trying out Rails again, this time the 3 version, but I got

  • 0

I was trying out Rails again, this time the 3 version, but I got stuck while writing tests for an action that I only call remotely.

A concrete example:

Controller

class PeopleController < ApplicationController
  def index
    @person = Person.new
  end
  def create
    @person = Person.new(params[:person])
    @person.save
  end
end

View (index.html.erb)

<div id="subscription">
  <%= form_for(@person, :url => { :action => "create" }, :remote => true) do |f| %>
    <%= f.text_field :email %>
    <%= f.submit "Subscribe" %>
  <% end %>
</div>

View (create.js.erb)

<% if @person.errors.full_messages.empty? %>
  $("#subscription").prepend('<p class="notice confirmation">Thanks for your subscription =)</p>');
<% else %>
  $("#subscription").prepend('<p class="notice error"><%= @person.errors.full_messages.last %></p>');
<% end %>

How can I test that remote form submission? I would just like to find out if the notice messages are being presented correctly. But if I try to do just

test "create adds a new person" do
  assert_difference 'Person.count' do
    post :create, :people => {:email => 'test@test.com'}
  end
  assert_response :success
end

It will say that the “create” action is missing a template.

How do you guys usually test remote calls?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:24:42+00:00Added an answer on May 15, 2026 at 9:24 pm

    Could you just use the ‘xhr’ function instead of the ‘post’ function? An example can be found at http://weblogs.java.net/blog/2008/01/04/testing-rails-applications, if you search for ‘xhr’. But even then, I’m curious, even with a remote call, don’t you need to return SOMETHING? Even just an OK header?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying out the example usage of codebrew rails-backbone , everything works fine but the
First time working with JSON in Rails and trying to figure out something which
I've been pulling my hair out trying to work with Time in Rails. Basically
I'm trying out the beast forum written in rails and will use this as
Came across this error when trying out the ruby on rails tutorial section with
I'm writing a feature for my rails app whereby for any arbitrary action that
I am currently trying out restful_authentication in rails. This is my routes.rb file ActionController::Routing::Routes.draw
I'm trying to send out an email with Rails 3 and Action Mailer. The
I'm coming from the .NET world, and I'm trying to figure out the Rails
I'm trying to create a ruby gem for rails out of a plugin I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.