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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:02:32+00:00 2026-06-02T05:02:32+00:00

I am trying to update Ruby on Rails to the version 3.1 . I

  • 0

I am trying to update Ruby on Rails to the version 3.1. I followed the Upgrading to Rails 3.1 screencast and all seems to work except for statements as

format.js { render(:update) { |page| page.redirect_to @article } }

In many controllers I have code like the following:

def create
  ...

  respond_to do |format|
    format.js { render(:update) { |page| page.redirect_to @article } }
  end
end

In all above cases, when I try to submit related forms performing JS requests, I get the following error:

ActionView::MissingTemplate (Missing template articles/update, application/update with {:handlers=>[:erb, :builder, :coffee], :formats=>[:js, :html], :locale=>[:en, :en]}. Searched in:
  * "/<MY_PROJECT_PATH>/app/views"
):

app/controllers/articles_controller.rb:114:in `create'

Rendered /<...>/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.3ms)

I know that the problem was related to RJS templates because them are not more available in the 3.1 release. So, in order to run some JavaScript code, in my controller files I may\should\can insert some JavaScript code as made in the following example:

format.js { render :js => "alert('Hello Rails');" }

BTW : …but, is it recommended to use JavaScript code directly in a controller file?

Considering the above code in the create controller action, I would like to redirect user to the @article path after a successful submission. I can do:

format.js { render :js => "window.location.replace('#{article_url(@article)}');" }

..but, how can I do the same thing by following the “Ruby on Rails Way to do things”? How RoR 3.1 would handle these cases?

  • 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-06-02T05:02:37+00:00Added an answer on June 2, 2026 at 5:02 am

    I’d go with:

    render js: %(window.location.href='#{article_path @article}')
    

    Or put something along the lines of this in your application_controller.rb:

    def js_redirect_to(path)
      render js: %(window.location.href='#{path}') and return
    end
    

    Then in your controllers you can just call:

    js_redirect_to(article_path @article)
    

    Note I just made this up – not tested 🙂

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

Sidebar

Related Questions

Short version: In trying to deal with a legacy database in Ruby-on-Rails, I've come
I'm trying to walk through Hartl's Ruby on Rails tutorial whilst upgrading his examples
I am trying update my version of sqlite3 on mac os x 10.5.7 I
I'm trying to update the custom meta for all WordPress posts where another custom
I'm trying to load up rails in the test environment using a ruby script.
I was trying to update Rails and I ran gem install rails from my
I am trying to install the new version of the twitter-bootstrap-rails gem (v2), but
I'm trying to learn some basics of Ruby on Rails and encountered a problem
hey I am newbie to ruby on rails and I am trying run a
I'm trying to create a User model for my Ruby on Rails app that

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.