Rails: can't pass variable to partial, what am I doing wrong?

I'm trying a few different ways to define and pass the local variable to the partial, but it keeps saying it's undefined:

in Show file:

<% @startups.each do |startup| %>
  <%= render :partial => "profile/startup" %>
<% end %>

in partial:

<%= simple_form_for [@commentable, @comment], :remote => true do |form| %>
  <%= form.input :content, label: false, :input_html => { :id => "#{startup.user_id}" } %>
  <%= form.submit "Submit" %>
<% end %>

These are the other ways I'm trying to pass the variable, but still getting undefined:

<%= render :partial => "user_comments/uac",  object: startup, as: startup %>
<%= render :partial => "user_comments/uac",  collection: startup, as: startup %>
<%= render :partial => "user_comments/uac", :locals => {:startup => startup} %>

Answers


Get rid of :partial. You haven't needed that in Rails for several versions.

The correct way of passing a local called startup to a partial is this:

render "profile/startup", startup: startup

Need Your Help

Push table data from django postgres model to remote oracle database

python django oracle postgresql

Hey guys i have a problem. There is an application that i built using django and it runs on postgresql. The application works perfectly but until recently , i was asked to push particular table dat...

Multidimensional arrays

php loops multidimensional-array

I have a php multidimensional array which looks like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.