Hi everyone,

Here is code in form.html.erb for partial view (controller rfqs).
Local var :sid was defined as the id of the record and it should be
passed into the partial view standards.html.erb as a local var.

<% @rfq.standards.each do |r| %>
<p><%= render :partial => 'standards', :locals => { :f =>
f, :sid => r.id } %></p>
<% end %>

Here is the standards partial view:

<%= f.association :standards, :collection =>
Standard.active_std.all(:order => 'name'), :label_method
=> :name, :value_method => :id, :prompt => "Choose std", :label =>
"standard:", :include_blank => true, :selected => sid %>

When standards rendered, there is an error saying that sid was not
defined. I did extensive search online about how to use :locals and
could not figure out what causes error. Any thoughts about the error?
Thanks.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Peter Vandenabeele at Jan 24, 2012 at 1:00 pm

    On Mon, Jan 23, 2012 at 9:41 PM, emc_lab wrote:

    Hi everyone,

    Here is code in form.html.erb for partial view (controller rfqs).
    Local var :sid was defined as the id of the record and it should be
    passed into the partial view standards.html.erb as a local var.

    <% @rfq.standards.each do |r| %>
    <p><%= render :partial => 'standards', :locals => { :f =>
    f, :sid => r.id } %></p>
    <% end %>

    Here is the standards partial view:

    <%= f.association :standards, :collection =>
    Standard.active_std.all(:order => 'name'), :label_method
    => :name, :value_method => :id, :prompt => "Choose std", :label =>
    "standard:", :include_blank => true, :selected => sid %>

    When standards rendered, there is an error saying that sid was not
    defined. I did extensive search online about how to use :locals and
    could not figure out what causes error. Any thoughts about the error?
    Not really, strange ...
    Is f passed correctly?
    What happend if you try passing different objects as sid (:sid => 1 e.g.).
    Does it work in that case?
    I assume your partial is named correctly `_standards.html.erb`

    Just a few random checks that may unveil the issue ...

    HTH,

    Peter

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 24, 2012 at 1:35 pm

    On 23 January 2012 20:41, emc_lab wrote:
    Hi everyone,

    Here is code in form.html.erb for partial view (controller rfqs).
    Local var :sid was defined as the id of the record and it should be
    passed into the partial view standards.html.erb as a local var.

    <% @rfq.standards.each do |r| %>
    <p><%= render :partial => 'standards', :locals => { :f =>
    f, :sid => r.id } %></p>
    <% end %>

    Here is the standards partial view:

    <%= f.association :standards, :collection =>
    Standard.active_std.all(:order => 'name'), :label_method
    => :name, :value_method => :id, :prompt => "Choose std", :label =>
    "standard:", :include_blank => true, :selected => sid %>

    When standards rendered, there is an error saying that sid was not
    defined. I did extensive search online about how to use :locals and
    could not figure out what causes error. Any thoughts about the error?
    Can you post the full error message please?

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 24, '12 at 12:18p
activeJan 24, '12 at 1:35p
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase