partial

passing values to partial in rails 3

随声附和 提交于 2019-11-30 05:03:51
Here is how I pass the values/variable to the partial: <%= render "partials/banner", :locals => {:text_1 => t(:"main.home.banner_text_1"), :text_2 => t(:"main.home.banner_text_2") } %> then in the partial: <%= text_1 %> <%= text_2 %> but getting "undefined local variable or method text_1" Where should I set the variable so it could be accesible from all views and layouts in my app? Thanks! If you have something that has to be displayed across all your views you can also create a application_helper method, Example: banner('Text', 'Content') Try this: Main page: <%= render :partial => 'layouts

Pickling wrapped partial functions

故事扮演 提交于 2019-11-30 04:54:54
问题 I am trying to create a picklable decorator using partial functions. However, I keep getting pickling errors when trying to do that. The first naïve example is as follows: def decorator(func): def wrapper(**kwargs): return partial(func, **kwargs) return wrapper @decorator def decorated(x, y=1, z=2): return x+y+z y5 = decorated(y=5) pickle.dumps(y5) Where partial is taken from functools . A bit less naïve attempt involves adding @wraps one line above def wrapper . This doesn't help. I'm not

python equivalent of functools 'partial' for a class / constructor

妖精的绣舞 提交于 2019-11-30 01:53:12
问题 I want to create a class that behaves like collections.defaultdict, without having the usage code specify the factory. EG: instead of class Config(collections.defaultdict): pass this: Config = functools.partial(collections.defaultdict, list) This almost works, but isinstance(Config(), Config) fails. I am betting this clue means there are more devious problems deeper in also. So is there a way to actually achieve this? I also tried: class Config(Object): __init__ = functools.partial

Reload Partial (Rails Ajax)

妖精的绣舞 提交于 2019-11-29 21:34:33
问题 I have a form that when I click submit, should update a partial that is on the same page... When I place this here: page.replace_html 'show_cards_div', 'Hello' It does just as it should, display hello when I need it to. But when I make it into this.... page.replace_html 'show_cards_div', :partial => "reloadThisPartial"` It simply does not do anything. What am I doing wrong? 回答1: The request might not be an Ajax call. Make Ajax call. User remote_form_for instead of form_for or use jquery.form

Nested BeginCollectionItem

你说的曾经没有我的故事 提交于 2019-11-29 18:05:33
问题 I'm using Steve Sanderson's BeginCollectionItem approach to add dynamic content. Everything works fine when I'm doing it on the first level. However, when try to implement a nested collection meaning a BeginCollectionItem in another BeginCollectionItem, it doesn't seem to work. My models are as follows: public class Order { [Key] [HiddenInput] public int id { get; set; } [Display(Name = "Order number")] public string number { get; set; } ... [Display(Name = "Payment method")] public List

is partial gz decompression possible?

自闭症网瘾萝莉.ら 提交于 2019-11-29 14:51:36
问题 For working with images that are stored as .gz files (my image processing software can read .gz files for shorter/smaller disk time/space) I need to check the header of each file. The header is just a small struct of a fixed size at the start of each image, and for images that are not compressed, checking it is very fast. For reading the compressed images, I have no choice but to decompress the whole file and then check this header, which of course slows down my program. Would it be possible

Stop ActiveRecord saving a serialized column even if not changed

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 10:44:49
This is very similar to Rails partial updates problem with hashes , but the question has not really been answered IMHO. The problem is this: I have a model with a serialized column: class Import < AR::Base serialize :data In my case, this data will, and should, not change after the first save/creation of the model. So I want to disable the feature of AR that always saves serialized columns (which is normally a good idea, as it can't detect those changes). I want to disable the saving because the data can be quite large, and the model will be updated frequently. I've already tried

Reloading partial in an rails app

折月煮酒 提交于 2019-11-29 09:10:47
问题 I want to reload a partial every 3 seconds on a 'new'-view in my rails app. I have this in my new.html.erb <h1>Controller#new</h1> This is my static content <%= render partial: 'dynamic' %> More Static content How do I get this partial reloaded every 3 seconds? Do I have to use unobtrusive javascript for this? How can I achieve this through ujs? 回答1: Put partial in div <div class="dynamic"><%= render partial: 'dynamic' %></div> You can do it by using jquery like this $(document).ready(

how to do partial page rendering (center content) with jsf2 templating via ajax (from menu)

笑着哭i 提交于 2019-11-29 08:54:09
i have been struggling getting this to work for 2 weeks, I am trying to merge info from BalusC from these 2 posts to ( link1 link2 ) to achieve partial page rendering of a center content area via a menu on the left. So the links on the left would update the center content via partial page rendering using <f:ajax> or maybe <a4j:ajax> via richfaces ------------------------------------------------------ | include1 link | | | include2 link | center content like include1.xhtml | | include3 link | | ------------------------------------------------------ my page-layout.xhtml (master template to be

MVC: Dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1

蹲街弑〆低调 提交于 2019-11-29 05:03:54
I am getting this error and I'm not sure if I am able to do this, here is my code.. Application controller public ActionResult AppView() { List<Application> apps; using (ISiteDbContext context = _resolver.GetService<ISiteDbContext>()) { apps = context.Applications.ToList(); } return PartialView("AppView", apps.OrderBy(a => a.Name).ToList()); } Render partial - this is within a view which is in the home controller. @{Html.RenderPartial("~/Views/Application/AppView.cshtml", new Example.Services.DAL.Application());} and my application view @model IEnumerable<Example.Services.DAL.Application> @{