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 7543721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:30:05+00:00 2026-05-30T08:30:05+00:00

I am posting a comment with some javascript. This calls the create action in

  • 0

I am posting a comment with some javascript. This calls the create action in the comments controller, which has a before filter that checks that the user belongs to the correct group. The before filter has a redirect to a dashboard page, but when I attempt to post a comment with a user who is not in the correct group, the comment does not get created, but the redirect does not happen.

Here is the before filter:

  def require_correct_user
    activity = Activity.find(params[:activity_id])
    unless (current_user.group == activity.group)
      redirect_to dashboard_path
    end
  end

I see the following in the server logs:

Started GET "/dashboard" for 127.0.0.1 at 2012-02-23 14:40:07 -0500
  Processing by UsersController#dashboard as */*

But the page stays the same in the browser and does not appear to be redirecting.

What is keeping the page from redirecting? Does it have to do with the comment being posted with javascript?

CLARIFICATION:

I am posting the comment to the create action with a form:

=form_tag({ :action => 'create', :controller => 'comments', :method => 'post' }

But I am submitting the form using the jquery-form plugin and calling ajaxForm.

  • 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-30T08:30:07+00:00Added an answer on May 30, 2026 at 8:30 am

    If you are using ajaxForm, then you are making an ajax request via XMLHttpRequest, which mean the browser window will not refresh. All you are doing, then, is redirecting the ajax request. For this to work as you would like, you need to return a status code to the ajax request that, when processed by the client browser causes the browser to load the alternate URL.

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

Sidebar

Related Questions

Okay, so I have this page, which has one Ajax:AsyncFileUploader also some other ajax
Posting this one for a friend. They have an Icefaces app that uses Icefaces's
After posting this question and reading that one I realized that it is very
I was posting some comments in a related question about MVC caching and some
< I have reviewed the related questions shown by SO before posting this >
Is there an easy way to comment out a loop which renders some html
This tiny JavaScript, along with some CSS is supposed to prevent duplicate entries into
I'm posting a ghost here, that daunts me for some years. It's a question
Is there any freeware library (controls) for ASP MVC implementing posting and displaying comments?
Posting a stack overflow question on stackoverflow.com, how amusing :-) I'm running some recursive

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.