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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:40:06+00:00 2026-05-29T09:40:06+00:00

My articles can appear on several sites, so as well as an article model

  • 0

My articles can appear on several sites, so as well as an article model with title, body etc and a site model with site_id, site_name etc, I have I have an article_site_permission model, with article_id, site_id and visible which can be either true or false.

On my article edit page, I’ve done a button_to:

<%= button_to 'Hide', article_site_permission_path(:id => @article_site_permission_id, :article_site_permission => {:visible => "false"}), :method => :put %>

This works – it changes the permission to false. And I can show the Show button which does the reverse.

Now I want to refresh the div that has the button in it by adding :remote => true to the button link. But where do I put my javascript?

Is it in the article_site_permission view – even though I’m looking at a view of the article itself?
Is it called update.js.erb?

Thanks for your help.


Update for clarity.

My button is on the articles/edit page. The button updates article_site_permissions. I want to go back to articles/edit and refresh the div that has the button in it.

I must edit the update controller for article_site_permissions, but where do I put the js to refresh the div?

  • 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-29T09:40:08+00:00Added an answer on May 29, 2026 at 9:40 am

    In your controller, redirect to the action you want (index, show, etc.). Do a

    respond_to do |format|
      format.js
    end
    

    under that action in your controller. Then, in the corresponding view, have a file named

    index.js.erb
    

    Or replace index with whatever action, just be sure to give it the same name as the action that’s calling it.

    EDIT

    I should also mention you are correct in adding the remote true to your button. It’s hard to tell from your question what action you’re trying to reach in which controller. If you’re trying to access the show action of the ArticleSitePermission controller, you’re doing well. However, it seems like you’re not trying to route to show. Check out this link for more info on routing to different actions.

    EDIT 2

    This should do it.

    <%= link_to 'Click me', {:controller => "article", :action => "update", :id => @article_site_permission_id },
          :remote => true %>
    

    Also, if all you want to do is redirect to the article, you don’t need to do js. Just redirect to articles#show

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

Sidebar

Related Questions

I have a database where you can select articles etc, users have an account,
I have a php web sites in wich I can manages articles. On the
An article has many articles that it refers to and many other articles can
I have a function where I can add articles and users can comment on
Say I have a controller, Articles but I want it to appear as a
Well I can't figure this one out... I have this Wordpress I use as
this is what i would like to do... In my site,each post can have
After reading several other blog posts and articles (references found below) there appear to
When a user visits mysite.com/articles, they see I a lists several articles. How can
Does anyone know where online copies of the old The Perl Journal articles can

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.