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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:12:11+00:00 2026-06-05T02:12:11+00:00

I have a ratings controller whose create action gets called via Javascript. I have

  • 0

I have a ratings controller whose create action gets called via Javascript. I have a create.js file in my ratings folder. I thought in order for the create.js file to be called you needed something like this

respond_to do |format|
    format.js
end

When I remove this however the create.js file is still being called. Is this because create.js is being called within the create action (i.e. the name of the method and .js file match)? Thanks!

Update: When format.js is missing, it cannot find the elements of the DOM. For example, if I have something like

$('#id_3').html('<%=escape_javascript render(:partial => 'show') %>');

The partial ‘show’ gets executed as I can see in the terminal but it cannot find the div ‘id_3’ and thus the partial never appears in the DOM. Any clarity would be appreciated, thanks

  • 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-05T02:12:14+00:00Added an answer on June 5, 2026 at 2:12 am

    That’s how Rails works: it renders the view that has the same name as the action.

    If you have multiple views with the same name (in different formats), you have to specify which one you want in the request and use the respond_to method to respond accordingly:

    def index
      respond_to do |format|
        format.js { ... }
        format.html { ... }
        ...
      end
    end
    

    GET /index.html will render the index.html.erb file (assuming you’re using ERB)

    GET /index.js will render the index.js.erb file

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

Sidebar

Related Questions

I have 2 tables called albums and photos with ratings being one of the
I have a controller action which looks like so - def upvote @post =
Right now I have this social media app, where I'm implementing ratings on users
When I try to pass the url value to the controller action , action
The pages from my site have ratings from 1 to 10, is there a
I have installed django-ratings application in my django project. Am wondering how best can
I have associated two models Businesses and Ratings . A business can be rated
In my controller I have: def rate @konkurrencer = Rating.where(:IP => @ip, :konkurrencer_id =>
Lets say I have a wine and beer model/controller along with a wine_review and
I have to select rating codes out of a ratings tag similar to the

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.