I want to create a link_to render :partial. I have two partials stored already in the view folder in which I call the link_to (which is the profiles views). Getting the JavaScript to load the data is the next step but I am having trouble structuring the link_to properly.
Here’s what I had:
<ul id="infoContainer">
<li><%= link_to render(:partial => "about") do %>About<% end %></li>
<li><%= link_to render(:partial => "other") do %>Other<% end %></li>
</ul>
Using these, both partials rendered in my show.html.erb and the links disappeared.
So I tried the following:
<ul id="infoContainer">
<li><%= link_to render(:partial => 'about'), :class => "a", :remote => true do %>About<% end %></li>
<li><%= link_to render(:partial => 'other'), :class => "o", :remote => true do %>Other<% end %></li>
</ul>
Both partials still show and the “About”/”Other” text links still don’t show.
UPDATE: So I may have the link_to working. It’s just not rendering anything. Gotta fix that with JavaScript I assume.
<li><%= link_to "About", (:partial => 'about'}, {:class => "a"}, :remote => true %></li>
<li><%= link_to "Other", (:partial => 'other'}, {:class => "o"}, :remote => true %></li>
Using the link_to above makes the URL: /profiles/1?partial=about
you’re using link_to incorrectly — please check the API / docs
it’s called either:
See:
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to
and perhaps:
link_to syntax with rails3 (link_to_remote) and basic javascript not working in a rails3 app?