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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:06:04+00:00 2026-05-18T22:06:04+00:00

I am learning Ruby on Rails, and I am very confused on how the

  • 0

I am learning Ruby on Rails, and I am very confused on how the controller-model-view relationship works for my application.

What I have now is a table full of comments (posts) users have made. What I want to do is let users click on a comment to see more information in a separate panel (ie, other database fields that weren’t initially shown, for example the user_id of the person who posted the comment).

In my _post.html.erb, I have something like:

<div class="post" id="<%= post.post_id %>" onclick = ?? >
<p>post.text</p></div>

What should go in onclick? I need a way for the onclick to call a helper/controller method which can load more information, and then put that in another div on a page (I’ve tried variations of using the controller and helper to call javascript which inserts html into the site, but that seems messier than it should be). From what I understand, I should create some kind of partial _postdetails.html.erb file that handles the actual displaying of the html, but I have no idea how to specific where that partial would go in the page.

Any help 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-05-18T22:06:05+00:00Added an answer on May 18, 2026 at 10:06 pm

    You can achieve what you want either by using Rails helpers or by writing the AJAX calls yourself.

    Personally I manually write all my AJAX calls using jQuery.
    You can also use Prototype which ships with Rails.

    That being said you can do.

    In your JS file :

    $("div.some-class").click(function()
    {
        $.ajax(
        {
          url:"url/to/controller/action",
          type:<GET>/<POST>,
          data://If you wish to sent any payload
        });
    });
    

    In your controller :

    def some_action
      #some computation
      render :update do |page|
        page["id_of_div_to_be_refreshed"].replace_html :partial => "some_partial"
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just learning ruby on rails and I have a table of user roles
I have just started learning ruby on rails. I have a doubt wrt routing.
I'm just learning Ruby on Rails. I've read a few books, I've watched lots
I am learning Ruby on Rails so I'm sure I'll find this out sooner
Is is that I'm a newbie learning Ruby, or does it really have more
I'm learning Ruby on Rails and doing the contactlist thing, 20 minute blog and
I'm learning Ruby on Rails. I'm using some associations (has_many :through, ...) But i'm
I'm just learning how to program in Ruby on Rails, and I'm really impressed
I have 2 years of experience in Ruby on Rails. I have basic knowledge
I'm just learning ruby and trying to understand the scope of code executed in

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.