partials

How to render a Partial from a Model in Rails 2.3.5

[亡魂溺海] 提交于 2019-12-07 05:27:03
问题 I have a Rails 2.3.5 application and Im trying to render several Partials from within a Model (i know, i know -- im not supposed to). The reason im doing this is im integrating a Comet server (APE) into my Rails app and need to push updates out based on the Model's events (ex. after_create). I have tried doing this: ActionView::Base.new(Rails::Configuration.new.view_path).render(:partial => "pages/show", :locals => {:page => self}) Which allows me to render simple partials that don't user

Multiple Layers of Deep Linking in AngularJS

大兔子大兔子 提交于 2019-12-06 09:05:57
I am attempting to place multiple controllers within my template partials with AngularJS- The problem I am encountering is that of the first layer, direct-linking to these sub-controllers and their related snippets. An example would be a management page for user accounts, say I am on a user-list and wanted to change a user from the list's password, I click on their change-password button, and want to redirect the user to #/ManageUsers/ChangePassword/?UserID=<uid here> rather than #/ManageUsers_ChangePassword/ or similar, but the Angular documentation (Or lack thereof) on the subject suggests

How to pass multiple locals to a nested partial

倾然丶 夕夏残阳落幕 提交于 2019-12-06 06:24:31
问题 This should be extremely straightforward and well documented, and I've done it several times, although there's something that's still killing me. I have a structure of partials calling nested partials. At some point one render call needs to pass an extra variable to the partial, although the rendering of the partial fails with a: undefined local variable or method `<variable name>' for #<#<Class:....> Here's my code for calling the render : = f.simple_fields_for :orders do |c| = render

ActionController::UrlGenerationError in Valuations#new

℡╲_俬逩灬. 提交于 2019-12-06 05:58:29
I've read other SO articles relating to UrlGenerationError 's which seem to point to singularization or plurization of a word, but I don't think that's the issue here. It works when I remove from valuations/_form.html.erb: <%= render "comments/comments" %> <%= render "comments/form" %> Submit the _form with :name & :tag_list , readd <%= render "comments/comments" %> <%= render "comments/form" %> and then refresh. What's the deal when nil? routes resources :valuations do resources :comments end comments_controller class CommentsController < ApplicationController before_action :load_commentable

How to use the partial in zendframework2

假装没事ソ 提交于 2019-12-06 03:17:30
问题 In ZF1 we use partial in layout.phtml file something like that $this->partial('header.phtml', array('vr' => 'zf2')); How we can do the same in ZF2? 回答1: this can be achieved by echo $this->partial('layout/header', array('vr' => 'zf2')); you can access the variable in view using echo $this->vr; don't forget to add following line in your view_manager of module.config.php file. 'layout/header' => __DIR__ . '/../view/layout/header.phtml', after adding it looks like this return array( 'view

Nodejs EJS partials with scripts in the head

我怕爱的太早我们不能终老 提交于 2019-12-06 02:21:50
问题 I'm working with EJS to render and server HTML pages from a Nodejs server. Some of the partials I include have scripts and stylesheets referenced in the head, but this causes the client to make multiple requests for the same file (for example if the parent view also includes that file) For example: <!-- file: parent.ejs --> <html> <head> <link rel="stylesheet" href="public/mystylesheet.css"> <script src="public/myscript.js"> </head> <body> <%- partial("partial.ejs") %> </body> </html> And in

Passing instance variable to js.erb file (Rails 3 / jQuery)

半腔热情 提交于 2019-12-06 00:20:09
问题 I have an "index.html.erb" file with the following: <%= render @users %> This renders "_user.html.erb" and outputs a button for performing a certain action on each user: <%= link_to "action", action_path(user), :id => "#{user.id}_action", :remote => true) %> I've set up my User controller to respond to the AJAX request by looking at "action.js.erb". In order to perform javascript methods on particular users within the partial, and I'd like to know how instance variables from my partial (such

Partial, Layout, Template rendering problems

拈花ヽ惹草 提交于 2019-12-05 18:21:38
The Situation So when I visit a page, I want to be able to apply a layout to a partial (I have three partials that I want with the same layout). Right now, I am trying to do it with this command: <%= render :partial => "shared/services/essay", :layout => "layouts/services/tab_pane", :locals => { :service => "essay" } %> where shared/services/essay goes something like: <% content_for :intro do %> <p> blah. </p> <% end %> <% content_for :workflow do %> <div> blah. </div> <% end %> <% content_for :value_prop do %> <p> blah. </p> <% end %> and `layouts/services/tab_pane' goes like: <div class="tab

Rails rendering instance variable from application.html.erb

假如想象 提交于 2019-12-05 10:48:07
I am following the Agile Web Development with Rails 4 book and I'm a bit confused on a part about rendering. The simple version of the question is... within the application.html.erb file there it says render @cart This is confusing because I thought that there needed to be a controller associated with that view in order to know which partial and @cart variable to use. Is it simply by naming convention that this line looks for a partial like _cart.html.erb? And in that case does it not actually know what @cart is until it renders that partial? Some clarification would be lovely. Thanks! This is

Using javascript code in Jade views - if(variable) shows undefined instead of passing

半城伤御伤魂 提交于 2019-12-05 06:42:15
So this is a recurring issue I have and haven't found another example on SO so here goes: When rendering Jade templates I get 'variableName' undefined even when using -if(variableName) in the template. Example (I'm using this as a partial for 'info' flash messages): -if(info) - if(info.length){ ul -info.forEach(function(info){ li= info -}) -} This returns 'info' is not defined instead of not rendering anything when there isn't a flash/info message. Does anyone know what I'm doing wrong? I'm aware of the typeof(variable) != 'undefined option as mentioned. If I wanted to do something like -if