helper

rails how to use helpers with ERB.new in service?

我的未来我决定 提交于 2020-06-17 15:26:21
问题 I have a service that uses an ERB file to render a template form. In the form I use several helpers, but they don't seem to be available in this context. how could I use my helpers in the rendering via ERB.new(template).result(binding) ? this is the error I'm getting: *** NoMethodError Exception: undefined method `image_encoded' for #<MyService> here's the call in the service app/services/my_service.rb file: ERB.new(template).result(binding) here's my helper app/helpers/my_helper.rb : module

Helper methods, ActionView and ActionController

…衆ロ難τιáo~ 提交于 2020-01-16 13:22:28
问题 I have a method in application_contoller.rb that includes a call to send_file . I'm calling it from a partial that's rendered by javascript, and getting the following error - ActionView::Template::Error (undefined method `send_file' for #<#<Class:0x0... I can kind of see what's happening - send_file is a controller method, so unavailable in the way I'm using it - my question is, how do I make it available? 回答1: You can define your method in controller as helper method: helper_method :send

MAC OSX Agents - how to launch multiple instances

帅比萌擦擦* 提交于 2020-01-15 17:54:12
问题 I am trying to create helper objects (it could be a daemon or an agent). This should be launch on demand and its multiple instances should be there, as you see for Chrome and Safari helpers. What Have I tried? I have referred these Apple Docs, Launchd Tutorial & Creating Start Up Items in Mac OS X There it is mentioned that for number of processes we should use NumberOfProcesses key, I used it but in Activity Monitor I see only one instance. And my plist looks like this <?xml version="1.0"

MAC OSX Agents - how to launch multiple instances

▼魔方 西西 提交于 2020-01-15 17:49:30
问题 I am trying to create helper objects (it could be a daemon or an agent). This should be launch on demand and its multiple instances should be there, as you see for Chrome and Safari helpers. What Have I tried? I have referred these Apple Docs, Launchd Tutorial & Creating Start Up Items in Mac OS X There it is mentioned that for number of processes we should use NumberOfProcesses key, I used it but in Activity Monitor I see only one instance. And my plist looks like this <?xml version="1.0"

Rails Return multiple content_tags from Helper module

試著忘記壹切 提交于 2020-01-10 19:59:06
问题 I've written the following helper: def section_to_html (block) case block[0].downcase when "paragraph" block.shift block.each do |value| return content_tag(:p, value) end end end It is currently parsed these arrays. ["paragraph", "This is the first paragraph."] ["paragraph", "This is the second.", "And here's an extra paragraph."] And it returns: <p>This is the first paragraph.</p> <p>This is the second.</p> Is there a way to accumulate the content_tag? so it returns: <p>This is the first

Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface?

风流意气都作罢 提交于 2020-01-09 11:14:29
问题 Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface? seemingly duplicate from here. but my idea is a bit different one, I just want to put a helper for my plugins(interface) shouldn't C# at least allow this idea? namespace MycComponent { public interface ITaskPlugin : ITaskInfo { string Description { get; } string MenuTree { get; } string MenuCaption { get; } void ShowTask(Form parentForm); void ShowTask(Form parentForm, Dictionary<string, object> pkColumns);

Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface?

久未见 提交于 2020-01-09 11:14:11
问题 Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface? seemingly duplicate from here. but my idea is a bit different one, I just want to put a helper for my plugins(interface) shouldn't C# at least allow this idea? namespace MycComponent { public interface ITaskPlugin : ITaskInfo { string Description { get; } string MenuTree { get; } string MenuCaption { get; } void ShowTask(Form parentForm); void ShowTask(Form parentForm, Dictionary<string, object> pkColumns);

How do I use the `--helper` flag in a rails 3 controller generator?

半城伤御伤魂 提交于 2020-01-03 08:48:12
问题 The documentation from rails generate controller says: [--helper] # Indicates when to generate helper # Default: true Now, it doesn't specify how to indicate a value. So, since the default is true, that means that excluding it won't indicate false, because… true is the default. So it must either be --helper=false or --helper false , but I tried both, and they both resulted in error false [not found] The good news is that it did not generate a helper, because it was confused, so I still got

call a helper function in controller in codeigniter

喜夏-厌秋 提交于 2020-01-01 19:21:31
问题 I created a helper for visit hits and it contains a function which inserts some data in to the database: hits_counter_helper.php : function count_hits($options = array()) { //Determine whether the user agent browsing your site is a web browser, a mobile device, or a robot. if ($this->agent->is_browser()) { $agent = $this->agent->browser() . ' ' . $this->agent->version() . ' - ' . $this->agent->platform(); } elseif ($this->agent->is_robot()) { $agent = $this->agent->robot(); } elseif ($this-

Joomla how to make an ajax call to an helper.php module

心不动则不痛 提交于 2019-12-31 04:12:12
问题 I create a module, not a component, a module because it should appears a number of times, on a number of pages in various positions I follow basic module creation In default.php I would like to make a ajax call to helper to refresh data, something like that : $.ajax({ url: '/index.php?option=mod_doodlike&format=raw&tmpl=component, all other parameters are in post Is it possible ? what is the exact URL ? what should I put in helper.php (public function , class myclass extends JController) or