similar to: Partials vs. Helpers

Displaying 20 results from an estimated 10000 matches similar to: "Partials vs. Helpers"

2006 Jul 16
1
Helpers for partials too ?
MainController implies main.rhtml, which will automatically have access to the methods inside MainHelper (in \app\helpers\main_helper.rb). Should not the partial templates called from main.rhtml via <%= render :partial => ''partial'' %> also have access to the methods in main_helper ? I have tried <% display_dates = create_display_dates(@events) %> and <%
2006 Mar 22
3
Rendering partials in ActionMailer?
Hello, Is anyone out there rendering partials successfully in ActionMailer templates? I am having trouble with this, and wasn''t sure if it was my configuration or something with a version of Rails I''m running. We''ve got over 15 mailer templates, all working like a charm. But we have a piece of shared code, that we''d really like to not have to copy &
2006 May 21
3
Where to put partials called from the application layout
Hello, My main application layout, app/views/layout/application.rhtml looks like this: something render partial_1 something else render partial_2 something else render partial_3 The partials are not really doing anything, i use them to keep the layout modular (i.e . to have ~30 lines instead of 200). Now, the question is where to put _partial_1.rhtml, _partial_2.rhtml, _partial_3.rhtml. If i am
2006 Jul 24
2
BIG JS limit? Using replace_html with partials containing JS
Hello, It''s pretty hard giving a practical example on this one. I have a partial which contains some generated Javascript. Something like: order_screen.rhtml ------------------------------------------- <h1>Order</h1> <div id="order_part"> <%=render :partial=>''order_new'' %> </div> <h1>Ordered products</h1>
2006 Jun 27
2
Render partials in folders
Right now I have partials in a view folder corresponding with my controller. ie: controller: example, view: example/_partial.rhtml and I call it with render :partial => ''partial'' How do I add the partial to another folder and call it? ie: controller: example, view: example/new_folder/_partial.rhtml render :partial => ''new_folder/partial'' # does NOT work
2006 Jun 24
3
Staying DRY -- can views share partials?
Let''s say I have a "main" controller/view and a "sub" controller/view. If I have defined a partial in "main" for the site header (_site_header.rhtml) can I share it with "sub" or does "sub" have to duplicate it, use a symbolic link to the file, or convert the cool partial into an ugly helper? It would be nice to have a shared placed
2007 Jan 11
0
Including partials in ActionMailer template files?
I have class called: class Notifier < ActionMailer::Base Then in my view for that class I have an rhtml file that holds the html for the email. I am trying to do <%= render :partial => "header" %> and I''m getting: ActionView::TemplateError (undefined method `controller_path'' for Notifier:Class) on line #1 of
2005 Dec 13
1
Locals and partials
Since i can''t figure out how to use heredocs with erb. im looking at solving my problem with partials, but since partials seem to have a completely separate namespace/scope im looking for a way to pass the entire scope of the calling rhtml to the partial. ------------------------------------------------------------------------ Hunter Peress
2006 Mar 20
1
AJAX in conjunction with partials
All, Trying to clear up some confusion on my part. If I make an Ajax call using Ajax.Request and in the controller method that I call, I do a render (:partial => ''whatever.rhtml''), should I expect that ''whatever.rhtml'' will be rendered in the browser or not? Put another way, is it in any way reasonable for me to think that Ajax.Request + partial render
2006 Mar 27
2
Trouble with rendering partials
This only works when the partial name matches the object name; if I change "threadtop" to "thread" then it works fine. Is this normal? I get the following error otherwise: "undefined local variable or method `thread''" index.rhtml --- <% for @thread in @threads %> <%= render :partial => ''threadtop'', :object => @thread
2005 Oct 15
1
Partials and controllers
Newbie question: From a _form.rhtml file I have: <%= render(:partial => ''item'', :collection => @items) %> In _item.rhtml I have: <% @tullt = h(item.body) %> <%= @itemdb = Group.find(:all, :conditions => "id = ''#{@tullt}''").map {|u| [u.name] } %> <%= @tullt % I think it would be better to
2006 Apr 26
0
partials or helpers: which to use?
Hi, Just wondering: when do people use a helper and when a partial? I''ve just converted a bunch of partials into helpers because I didn''t like the syntax of partials where I can had to pass in a :locals hash every time. I wonder what advantages a partial has over a helper and vice versa. I guess a partial has easier access to the controller and various assigned variables,
2006 May 10
4
using partials in a for loop
I''m trying to write a partial for a link_to_remote that i''m using over and over again, but simply moving the code to a partial doesn''t seem to work. Here is how I have it set up: class_planner.rhtml: <% for course in @courses %> <%= render :partial => "class_list" %> <% end %> _class_list.rhtml: <li> <%= link_to_remote
2006 Aug 10
6
Partials - asked before never got reply
I''m trying to figure out how multiple partials in one page would be configured when they are based on some action in the controller. As an example - I have a main/welcome page. If someone new or a user not logged in arrives at this page I display both a registration form and a login form. However, if they are logged in then those forms should not show up on that page. Also should
2007 Dec 27
4
Help With partials
ok i''m having problems moving a piece of code into a partial I have a line in a view: <%= image_tag( createturing ) %> moving to a partial _createturing.rhtml and changing the view to: <div id="turing"><%= render(:partial => "createturing") %></div> gives errors: ActionView::TemplateError (can''t convert nil into String) on
2006 Sep 26
0
Is it possible to render RXML partials in RHTML templates?
I have a RHTML template and I would like the output of a RXML partial to be embedded within it. When I do <%= render(:partial => ''list_edit'') %> where there exists a _list_edit.rmxl file, I get XML parsing errors in the browser - I believe because the partial is causing the rendered content to be identified as XML instead of HTML. Is there any way to
2012 Sep 05
2
Partials and helpers
Hi, Is there any reason why helpers cannot render partials? I would like to do something like this in the layout: <body> <%= magic_header %> <%= yield %> </body> and then have a magic_header helper def magic_helper ...do some magic... render partial: "magic_helper" end Why is this wrong? Cumprimentos, Luís Ferreira -- You received this
2006 May 21
2
Nooby partials / component problems
I''m stumped on what seems like should be a fairly easy thing, so I hope someone can point out my error. I wanted to show a few things on every page, so I added an application level template in "layouts". I added my styles in there, and put the controller name and action name into the TITLE tag for my own reference. So far so good - works like expected. Then I wanted to
2006 Apr 12
4
CSS and Javascript with partials and layouts
Hi, I''m developing an application that uses a layout called main on every page. Most of the individual pages are represented with a single partial template, but there are several pages that are composed of multiple partials. My main layout looks something like this: Code: <html> <head> <title><%= @title %></title> <%= stylesheet_link_tag
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