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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:10:45+00:00 2026-05-26T12:10:45+00:00

I’ve never programmed before and am having difficulty getting link_to to render the corresponding

  • 0

I’ve never programmed before and am having difficulty getting link_to to render the corresponding :partial in a users’ profile inside of my Rails 3 app. All in all there are three partials:

  1. _profile_credits (I’m focusing on _profile_credits for the sake of this question.)
  2. _profile_about
  3. _profile_reviews

What I want to do is click the following:

<li><%= link_to "Credits", profile_credits_profile_path(:id => @profile.id), :remote => true %></li>

And have the following partial (_profile_credits) load and render each credit in @user.credits:

<% for credit in @user.credits %>
  <div class="credit">
  </div>
<% end %>

Where I’m trying to render the partial is beneath the links and inside of the div container. The HTML below shows the position of the links within the div and where I’d like the info from the partials to load:

<div id="tabs">
  <ul id="infoContainer">
    <li><%= link_to "Reviews", profile_reviews_profile_path(:id => @profile.id), :remote => true %></li>
    <li><%= link_to "About", profile_about_profile_path(:id => @profile.id), :remote => true %></li>
    <li><%= link_to "Credits", profile_credits_profile_path(:id => @profile.id), :remote => true %></li>
  </ul>
  <div id="tabs-1">
    ##load information from the partials inside `<div id="tabs-1">
  </div>
</div><!-- end tabs -->

And the rest of my code…

My profiles_controller#profile_credits action:

def profile_credits
  respond_to do |format|
    format.js { render :layout => false }
  end
end

In my routes.rb:

resources :profiles do
  get :profile_credits, :on => :member
end

My profile_credits.js.erb:

$( "#tabs" ).html( "<%= escape_javascript( render (:partial => "profile_credits", :locals => { :id => @profile.id } ) ) %>" );

At the moment nothing happens when I click a link. I’ve tried following the various Rails 3 UJS examples but can’t get it. At one point I specified more in the ProfilesController profile_credits action. However, if I was on someone else’s profile my credits were loading, not the credits of the user whose profile I was browsing. Can anyone help me figure this out?

  • 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-26T12:10:45+00:00Added an answer on May 26, 2026 at 12:10 pm

    I finally got this to work. Given a <div> that contains a <ul> navigation and a <div> for the loaded content, here is my code:

    HTML for my container:

    <div id="tabs">
      <ul id="infoContainer">
        <li><%= link_to "Reviews", profile_reviews_profile_path, :remote => true %></li>
        <li><%= link_to "About", profile_about_profile_path, :remote => true %></li>
        <li><%= link_to "Credits", profile_credits_profile_path, :remote => true %></li>
      </ul>
      <div id="tabs-1">
        <%= render :partial 'profile_reviews %> #default
      </div>
    </div><!-- end tabs -->
    

    _profile_credits.html.erb partial:

    <% for credit in @user.credits %>
      <div class="credit">
      </div>
    <% end %>
    

    profile_credits.js.erb:

    $( "#tabs-1" ).html( "<%= escape_javascript( render (:partial => "profile_credits" ) ) %>" );
    

    profile_credits.rb controller:

    def profile_credits
      @profile = Profile.find(params[:id])
      @user = User.find(@profile.user_id)
      @credits = User.find(@profile.id).credits
      respond_to do |format|
        format.html { render :layout => nil }
        format.xml
        format.js { render :layout => nil }
      end
    end
    

    That did it.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.