Displaying 20 results from an estimated 3000 matches similar to: "Locals do not appear in partial unless collection is explici"
2006 Dec 13
4
RSpec and simply_helpful
Hi All
I''m having some problems running my view specs when using
simply_helpful.  I have it semi-working via the following:
module SimplyHelpfulHelper
  def self.included(base)
    base.send :include, SimplyHelpful::RecordIdentificationHelper
    base.send :include, SimplyHelpful::RecordTagHelper
  end
end
context "The index template" do
  setup do
    @shift =
2008 May 08
0
stub sub partials when testing partial with rspec
Hello all
I prefer to use many partials. It makes my code more DRY
Also I use rspec, and when I have to test partial with sub partials I
have a problem.
if I stub render, then my partial will not be rendered. If i do not
stub render it tries to render sub partial (and i don''t need this)
Not  very long googling did not bring the answer, so I made very dirty
and IMHO dangerous  function
2007 Aug 14
12
expect_render, why does there need to be a warning
There is a warning on the web site about expect_render and stub_render:
"WARNING: expect_render and stub_render, while very useful, act
differently from standard Message Expectations (a.k.a. mock
expectations), which would never pass calls through to the real
object. This can be very confusing when there are failures if you''re
not aware of this fact, because some calls will be
2006 Aug 01
2
Partial Naming Madness
Hi, I am having the following issue with a partial.  During initial page 
load, I am doing a "render_partial_collect ''foo'', @foos", and all goes 
well.  Each foo partial makes use of a variable inside called ''foo'' (and 
can get foo.id etc).
After all the partials are loaded, I need to :update a div corresponding 
to one of the partials (ie re-load the
2006 Jan 03
3
render :partial stops setting local variables.
I''m not sure what happened, or what change has caused this to happen, but
render :partial (or any render for that matter, doesn''t seem to let me set
local variables via the local_assigns argument hash.
for example
<%= render :partial ''edit'', :username => @user.username %>
used to allow that username was a local variable in my _edit.rhtml partial
2009 Oct 28
2
render :file cached?
In my application I have a controller/view that displays the contents
of an audit log file
  def audit_log
    render :layout => ''table'',  :file => AUDIT_LOG
  end
The audit log is updated frequently but the render call does not re-
read the file so it gets stale.  Is there a way to tell render to
check the file timestamp and reload as needed?
2006 Feb 14
22
Teaching Models to Render Themselves in the Controller
I am trying to teach my models how to render themselves, i.e.
<%= my_model_object.render() %>
Let me explain my reasoning and proposed method before this gets shot  
down as anti-MVC.
Let''s say I am writing a contact-management application. I have a  
class Contact. I will need to display this class all over the  
application. My first choice is to use a partial.
Now I can
2010 Feb 12
2
How to source files from a search path?
Suppose some environment variable (say MY_R_INC) has a number of
paths. I want to source some file relative to some path in $MY_R_INC
(just as #include in C++ does, which looks for header file in a number
of directories). I RSiteSearch'ed, but I don't find any function that
satisfies my need. Could somebody let me know if I overlooked
something?
2005 Aug 19
3
accessing DB result in template
hello,
  I have the following in my controller
def totalmembers
    @total = User.find_by_sql "SELECT COUNT(*) as count FROM users "
end
now inside my template how do i access the field "count" from the  
query so i can print out the number of members ?
I tried everythign like <%= @total.count %> but nothing works.
thanks
adam
2006 Apr 10
8
Advice on Similar Views with Helpers
I have some embedded tables that form different sections of a view.  I 
find that I use the same look for certain ones which means I have to 
duplicate the same exact table for each section that''s similar.
Is there a way to do.. hmm.. well.. kind of like what a layout does 
using @content_for_layout, but for a partial.  Does that make any sense 
whatsoever? :)
OK so here''s some
2011 Apr 06
1
Time to fix PartialRenderer#partial_path
For the longest time PartialRenderer#partial_path has prefixed the
prefix of the current controller when it is nested in a module. This
hasn''t been a problem (because nesting controllers wasn''t that common)
but with 3.1 striving for better engine support, this problem is now
larger because all of your controllers for an engine will be nested
and it makes doing <%= render
2007 Apr 12
11
Test if view renders appropriate partial?
Hello,
  I am testing out a partial that calls another, general purpose
partial as part of its processing.  Is there a class I can mock in
Rails views to accomplish what I need?  That is, could I do something
like the following:
SomeClass.should_receive(:render).with(:partial => "foo", :locals => {
:bars => bars })
I tried breakpointing the view, and it looks like I am greeted
2007 Jul 19
7
NoMethodError in partial driving me mad
Hello,
i simplified have a news model, a news category model and a news
controller.
my _news.rhtml partial renders a single news entry.
in my controller there are the actions show and show_category.
if the "show" action is called, a single news item is rendered through
my partial with no errors.
if the "show_category" action is called, i get a NoMethodError while
displaying
2006 Jun 08
1
No rhtml, rxml, or delegate template found
hi ,
i''m having a problem with rendering a partial , the partial is in the 
apps/view/polls folder with the name : _antwoorden_user.rhtml
in the view i''m rendering it with
<% if @user %>
 <%=  render :partial => ''polls/antwoorden_user'', :locals => {:poll => 
@poll, :user => @user} %>
<% else %>
....
gives me the error =>
 No
2009 Feb 25
9
local variables in partials lead to NameError
I know I must be doing something dumb, but I can''t seem to send a
local variable to my partial. The below code leads to the following
error:
NameError in Residential_listings#new
undefined local variable or method `foo'' for #<ActionView::Base:
0x3fb53f8>
I am trying to call the variable ''foo'' in a partial called
_attachment.html.erb, which is nested in
2005 Jun 29
2
Complex helper with block help
Hi everyone,
I am writing a helper function that takes a parameter and block and
wraps some HTML around it. e.g.
def box_with_caption(caption, &block)
	data = capture(&block)
	buffer = render_partial("helpers/box_caption", :caption =>
caption)
	buffer << render_partial("helpers/box_data", :data => data)
	buffer
end
however, when I attempt the following,
2007 Sep 25
21
form_for and partials
I love form_for, but I really hate
<% form_for :person, @person, :url => {...} do |f| %>
   ...
   <%= render :partial => ''form'', :locals => {''f'' => f}
   ...
<% end %>
I''ve been thinking of instead allowing
<% form_for :person, @person, :url => {...} do |f| %>
   ...
   <%= f.partial ''form''
2009 Feb 03
1
Passing args to generator
I have some default_options in generator and when I wish to change they
value with --option_name I get only logical true instead of string
...
default_options :option_name => "Some string"
...
def add_options!(opt)
  opt.separator ''''
  opt.separator ''Options:''
  opt.on("--option_name","Some Text") { |v| options[:option_name] = v
2005 Apr 13
2
render_partial & RXML
Does render_partial work within a RXML file?  I am attempting the following:
xml.users do
    for user in @users
        render_partial ''user'', user
    end			
end
All that is output is:
<user>
</user>
Without any exception or anything to indicate that I''m doing something
wrong.  Does anyone have any experiece with this?
Josh
2005 Apr 06
6
Mimic something like layout on a smaller scale?
I need to add various header and footer dressings around groups of form
fields for GUI goodness, and am wondering if there''s already something out
there that will suit my needs. These headers/footers have special properties
for display(title, help links, etc...). I want to be able to easily take
advantage of the existing HTML helper methods provided for controllers, in a
mini-layout type