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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:35:03+00:00 2026-06-16T00:35:03+00:00

I am trying to render the user detail on index page when user is

  • 0

I am trying to render the user detail on index page when user is clicked.

I am having the list of users in index page like

<% @users.each do |user| %>
   <%= link_to user.name, '', {:id => user.id, :name => 'user', :remote => true}
<% end %>

In my javascript

$('#mydiv').html("<%= escape_javascript(render(:partial => '/users/show', :locals => {:id => #{params['id']}})) %>"

but I couldn’t able to render the user details, because param ‘id’ is not passing to this page.

How to get this param and render the partial in the index page when user is clicked.

  • 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-16T00:35:04+00:00Added an answer on June 16, 2026 at 12:35 am

    In this case you should review your code a little. You should directly call the show method in your link and edit your controller to have it responding to JavaScript:

    View code:

    <%= link_to user.name, user_path(user), remote: true %>
    

    Controller code:

    def show
        @user = User.find(params[:id])
        respond_to do |format|
            format.html
            format.js
        end
    end
    

    And create a new view called users/show.js.erb

    $("#mydiv").html("<%= escape_javascript(render(:partial => '/users/user_show', :locals => {:user => @user})) %>");
    

    This view is calling a partial view where you can render all your user data. This view is called users/_user_show.html.erb

    <div class="myuser">
        <%= user.name %>
    </div>
    

    Hope that helps

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

Sidebar

Related Questions

I'm rendering a todo list for a user like so <%= render @user.todos %>
I have a User model that has many posts. Im trying to render the
In trying to render a form im getting: NameError in Deals#new Showing /Users/nelsonkeating/Desktop/ReminDeal1/app/views/deals/_form.html.erb where
I am trying to render a partial that displays a list of names (that
I have some user generated content I'm trying to render on my site. The
I've never programmed before and am having difficulty getting link_to to render the corresponding
I'm trying to create simple ExtJs application that manages Users and User's Roles. Set
I'm trying to render a page of 'projects' retrieved from a database. There are
I am trying to render a string over an image chosen by user via
So I am trying to render a partial view into my page and I

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.