helpers

Rails: Routing without plurals gives strange helpers

只愿长相守 提交于 2019-12-02 08:55:29
I am getting a strange named helpers with this setup: In config/routes.rb I have: Qtl::Application.routes.draw do resources :qtl_table do collection do get 'search' end end ... end rake routes outputs this: search_qtl_table_index GET /qtl_table/search(.:format) {:action=>"search", :controller=>"qtl_table"} qtl_table_index GET /qtl_table(.:format) {:action=>"index", :controller=>"qtl_table"} POST /qtl_table(.:format) {:action=>"create", :controller=>"qtl_table"} new_qtl_table GET /qtl_table/new(.:format) {:action=>"new", :controller=>"qtl_table"} edit_qtl_table GET /qtl_table/:id/edit(.:format)

HTML helpers in Webform?

最后都变了- 提交于 2019-12-01 18:24:32
问题 I have a old site that I want to use something like HTML helpers to generate special HTML(in this case complexed buttons). I know how this works in ASP.NET MVC but how can I do it in Webform(not Razor). I have read suggestions on static methods like this : public class Helpers { public static string Label1(string target, string text) { return String.Format("<label for= '{0}'>{1}</label>", target, text); } } But how is this used in the Webform? BestRegards 回答1: At your solution. Add a special

Generate full url to javascript in rails (similar to javascript_path, but url)

余生颓废 提交于 2019-12-01 17:23:18
How is it possible to generate an absolute link to the javascript file. I assume there should be something like the one below (which unfortunately does not seem to be available): javascript_url 'main' # -> 'http://localhost:3000/javascripts/main.js' instead of: javascript_path 'main' # -> '/javascripts/main.js' I need the absolute URL because that javascript file will be used in a bookmarklet. Additionally I need the same for css file. Thanks, Dmitriy. Absolute URLs to javascript and css files are now available in Rails 4 in ActionView::Helpers::AssetUrlHelper module via Asset Pipeline. In

How to use elasticsearch.helpers.streaming_bulk

爷,独闯天下 提交于 2019-12-01 16:34:33
Can someone advice how to use function elasticsearch.helpers.streaming_bulk instead elasticsearch.helpers.bulk for indexing data into elasticsearch. If I simply change streaming_bulk instead of bulk, nothing gets indexed, so I guess it needs to be used in different form. Code below creates index, type and index data from CSV file in chunks of 500 elemens into elasticsearch. It is working properly but I am wandering is it possible to increse prerformance. That's why I want to try out streaming_bulk function. Currently I need 10 minutes to index 1 million rows for CSV document of 200MB. I use

Generate full url to javascript in rails (similar to javascript_path, but url)

一笑奈何 提交于 2019-12-01 16:10:51
问题 How is it possible to generate an absolute link to the javascript file. I assume there should be something like the one below (which unfortunately does not seem to be available): javascript_url 'main' # -> 'http://localhost:3000/javascripts/main.js' instead of: javascript_path 'main' # -> '/javascripts/main.js' I need the absolute URL because that javascript file will be used in a bookmarklet. Additionally I need the same for css file. Thanks, Dmitriy. 回答1: Absolute URLs to javascript and css

Rails article helper - “a” or “an”

冷暖自知 提交于 2019-12-01 02:39:45
Does anyone know of a Rails Helper which can automatically prepend the appropriate article to a given string? For instance, if I pass in "apple" to the function it would turn out "an apple", whereas if I were to send in "banana" it would return "a banana" I already checked the Rails TextHelper module but could not find anything. Apologies if this is a duplicate but it is admittedly a hard answer to search for... None that I know of but it seems simple enough to write a helper for this right? Off the top of my head def indefinite_articlerize(params_word) %w(a e i o u).include?(params_word[0]

Rails article helper - “a” or “an”

霸气de小男生 提交于 2019-11-30 21:27:39
问题 Does anyone know of a Rails Helper which can automatically prepend the appropriate article to a given string? For instance, if I pass in "apple" to the function it would turn out "an apple", whereas if I were to send in "banana" it would return "a banana" I already checked the Rails TextHelper module but could not find anything. Apologies if this is a duplicate but it is admittedly a hard answer to search for... 回答1: None that I know of but it seems simple enough to write a helper for this

CakePHP select default value in SELECT input

时间秒杀一切 提交于 2019-11-30 08:26:52
Using CakePHP: I have a many-to-one relationship, let's pretend it's many Leafs to Trees. Of course, I baked a form to add a Leaf to a Tree, and you can specify which Tree it is with a drop-down box ( tag) created by the form helper. The only thing is, the SELECT box always defaults to Tree #1, but I would like it to default to the Tree it's being added to: For example, calling example.com/leaf/add/5 would bring up the interface to add a new Leaf to Tree #5. The dropdown box for Leaf.tree_id would default to "Tree 5", instead of "Tree 1" that it currently defaults to. What do I need to put in

Rails 3. How to add a helper that ActiveAdmin will use?

大憨熊 提交于 2019-11-30 04:36:29
I'm creating a helper to be used by Formtastic but I get the undefined local variable or method error. I don't know where to put it so it can work. I already tried in the application_helper.rb and in app/helpers/active_admin/view_helpers.rb You can define them in app/helpers/ as you tried but you need to include them trough the active admin's initializer like this: # in config/initializers/active_admin.rb ActiveAdmin.setup do |config| .... end module ActiveAdmin::ViewHelpers include ApplicationHelper end alony You need to put your helper functions in app/helpers/active_admin/views_helper.rb

cakephp accessing view attributes/variables from within a helper

試著忘記壹切 提交于 2019-11-29 17:45:38
问题 is there a reasonable way to access the view attribute "passedArgs" (or any similar) /* view */ $this->passedArgs from within a Helper? I'd be happy to customize the _construct() of the helper or to customize the app_helper... but I don't want to have to pass $this->passedArgs into the helper on every view or usage. 回答1: Cake 2.x and 3.x You can look up your variables in the _View object: $this->_View->viewVars['foo']; Cake 1.x If you grab the current view object from within the helper you