helpers

“undefined method” when calling helper method from controller in Rails

巧了我就是萌 提交于 2019-12-17 21:52:40
问题 Does anyone know why I get undefined method `my_method' for #<MyController:0x1043a7410> when I call my_method("string") from within my ApplicationController subclass? My controller looks like class MyController < ApplicationController def show @value = my_method(params[:string]) end end and my helper module ApplicationHelper def my_method(string) return string end end and finally, ApplicationController class ApplicationController < ActionController::Base after_filter :set_content_type helper

Zend Framework Widget Tutorial question

一曲冷凌霜 提交于 2019-12-12 17:28:34
问题 I try to follow this tutorial, but I can't get it to work: http://weierophinney.net/matthew/archives/246-Using-Action-Helpers-To-Implement-Re-Usable-Widgets.html I did everything as described, but I don't know how to make it available in my controllers. My filesystem looks like this: - application - controllers - IndexController.php - modules - user - configs user.ini - controllers - forms Login.php - helpers HandleLogin.php - views - scripts login.phmtl profile.phtml Bootstrap.php - views

prestashop multiple checkboxes do not save values

断了今生、忘了曾经 提交于 2019-12-12 05:36:31
问题 I can't figure out why the checkbox values are not saved in the database using helpers. Trying to save some customers ids from my module's setting : The array : $custs = Customer::getCustomers(); foreach ($custs as $key => $value) { $options[] = array( 'id_customer' => (int)$value['id_customer'], 'infos' => $value['firstname'].' '.$value['lastname'].' | '.$value['email'] ); } The checkboxes : 'input' => array( array( 'type' => 'checkbox', 'label' => $this->l('Customers'), 'desc' => $this->l(

how do display html + css tags in a rails helper method

别等时光非礼了梦想. 提交于 2019-12-11 04:14:44
问题 I am trying to write something like this, but it display me the whole string. Not the formatted "Today!". Feel free to tune my method :) thanks def days_left(deadline) (if deadline.date-Date.today == 0 "<strong>Today!</strong>" elsif deadline.date-Date.today < 1 "<div class='expired'>Overdue</div>" else (deadline.date-Date.today).to_i end) end 回答1: def days_left(deadline) (if deadline.date-Date.today == 0 "<strong>Today!</strong>" elsif deadline.date-Date.today < 1 "<div class='expired'

Yii2: Finding file and getting path in a directory tree

六月ゝ 毕业季﹏ 提交于 2019-12-10 22:04:45
问题 I'm trying to search for a single filename in a bunch of directories and returning its path. I thought FileHelper::findFiles() would be a helping hand but it seems it doesn't accept a filename to search for but just a particular root directory and then it returns an array of found filenames. Anyone who knows another Yii2 helper to accomplish this? 回答1: You should simply try: $files = yii\helpers\FileHelper::findFiles('/path', [ 'only' => ['filename.ext'], 'recursive' => true, ]); Read more

CakePHP - TinyMceHelper helper error: Method TinyMceHelper::__name does not exist

笑着哭i 提交于 2019-12-10 19:55:32
问题 So I'm wanting to implement the TinyMce helper. I've followed instructions from the cakephp bakery but am still getting a error. This is the helpers array in my project controller: var $helpers = array('Form', 'Time', 'Crumb', 'Text', 'Tinymce'); This is the tinymce helper I downloaded: <?php class TinyMceHelper extends AppHelper { // Take advantage of other helpers var $helpers = array('Javascript', 'Form'); // Check if the tiny_mce.js file has been added or not var $_script = false; /** *

Cakephp Helpers in Views and $this

天涯浪子 提交于 2019-12-10 17:47:46
问题 I'm trying to determine what the best standard is for using helpers in views whether is should be echo $form->input(); or echo $this->Form->input(); In the CakePHP manual ver 1.2 the Helper class is accessed by the helper object directly, whereas in the 1.3 book the helper object is accessed through the View. Does this matter? Leo 回答1: It really only matters because of the possibility of having a collision that will "wipe out" your access to the helper. Say I had a model named Form and

Helper “fields_for” not working

懵懂的女人 提交于 2019-12-10 04:35:42
问题 I'm using nested attributes, but the fields aren't loaded in my view. Someone know what I missing? Rails 3.1, Ruby 1.9.2 Model 1: class Traditions::Material < ActiveRecord::Base has_one :material_asset, :dependent => :destroy validates_presence_of :title accepts_nested_attributes_for :material_asset end Model 2: class Traditions::MaterialAsset < ActiveRecord::Base belongs_to :material has_attached_file :asset validates_attachment_presence :asset end View (HAML): = form_for @material, :html =>

WooCommerce - get_order() is not working

十年热恋 提交于 2019-12-10 04:26:52
问题 I'm trying to create a function that will retrieve an order by its ID. For some reason I can't get the WooCommerce global function get_order to work. I'm passing a valid order id to the function and trying to print it out to verify that it's working. The function has been placed in my functions.php file. function getWC_order_details($id){ global $woocommerce; $order = get_order( $id ); print "<pre>"; print_r($order); print "</pre>"; } I have tested echoing other data out of the function

How to add a link_to in a select_tag with Rails/ERB?

烂漫一生 提交于 2019-12-10 03:19:03
问题 I have the following code in my index.html.erb <%= select_tag 'team_id', options_for_select(@teams.map{|team| ["#{team.name} # {team.nick}", team.id] }) %> Where would I add a link_to helper within that block? Can I even add a link_to for select_tag? The desired link_to would go to '/Teamleader/ID_OF_OPTION_PICKED' UPDATE: To be more clear; when a user selects an option from the select tag, I want to redirect the page to the desired link (from link_to). 回答1: <%= select_tag 'team_id', options