Questions tagged [helpermethods]
85 questions
1
vote
1 answer
Why do I need a helper method to recursively search a binary search tree?
Here is the code for the implementation of the Binary Search Tree:
public class BST> {
BSTNode root;
public T search(T target)
{
//loop to go through nodes and determine which routes to make
BSTNode tmp =…
Patrick
- 67
- 7
1
vote
1 answer
How set up and call a rails method in the view to update an attribute of an object
I need some help in figuring out how to set up a helper method and then call in in the view. What i need to do is update a single attribute of a model object.
How I plan to do this is to call a helper method Bid, which will update the attribute by…
Clay McCullough
- 69
- 8
1
vote
2 answers
Recursion in helper methods (Java)
I am practicing recursion and using a recursive helper method. In my helper method, an error appears saying that
The method someMethod(K) in the type Tree is not applicable for the arguments (K, List, int).
However, I do not want to use the…
user4060080
1
vote
1 answer
Problem with returning values from a helper method in Rails
I want to print some objects in a table having 2 rows per object, like this:
Name Price
Content 123
I wrote a helper method in products_helper.rb, based…
True Soft
- 8,246
- 6
- 48
- 77
1
vote
2 answers
suggest helper method for this Java Generics piece of code please
I accidentally wrote this piece of code .
static List foo(List fillthis,List super Integer> readlist){
for(Object i:readList){
if(i instanceof Integer)
fillthis.add(i);
}
return fillthis;
…
Sarabjeet
- 264
- 1
- 15
1
vote
1 answer
Helper methods are not being seen (Rails 4 engine)
I have defined a helper method as such (for my rails engine):
module Xaaron
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
rescue_from ActiveRecord::RecordNotFound, :with =>…
user3379926
- 3,527
- 5
- 22
- 40
1
vote
4 answers
Recursive helper method
i cant find the right solution for this exercise, here is the task:
(Occurrences of a specified character in an array) Write a recursive method that
finds the number of occurrences of a specified character in an array. You need to
define the…
Peter
- 309
- 2
- 5
- 13
1
vote
2 answers
StackFrame.GetMethod().Name
I'm using this helper to resolve the name of the method that is currently being executed for logging purposes.
[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetCurrentMethod()
{
StackTrace st = new…
g5insider
- 99
- 9
1
vote
1 answer
How to use "count" in rails to show how many projects/tasks user has?
I defined method 'count' in my tasks controller as:
def count
@count = current_user.tasks.count
end
I'm not sure how to show that in my tasks views. Do I just use Tasks count: <% @count %>? How do I get in my view how many tasks the user…
sent-hil
- 16,955
- 15
- 53
- 71
1
vote
3 answers
Editing world-flags output
I am trying to edit the output on the world-flags gem, in the documentation it says the following:
You can customize the output by the flag view helper methods:
WorldFlags.flag_list_tag = :div
WorldFlags.flag_tag = :span
WorldFlags.flag_text =…
Jeremy Lynch
- 5,257
- 2
- 41
- 55
1
vote
3 answers
How to organize helper functions
I need to create lot of helper routines for converting strings.
Something like :
String Function1(String s) {}
I would like to call them from any Activity.
What is the best way to do this ? Do I need to create a class or not ? I was thinking just…
Milan
- 383
- 1
- 6
- 14
1
vote
1 answer
link_to links not working in other views after using devise
I'm working on a rails app that uses devise.
I added other models to the app and the links in those new views (default "link_to") are not working. For example, I scaffolded a new model and the links for those views do not change the URL (hard…
pvskisteak5
- 3,932
- 3
- 20
- 26
0
votes
2 answers
CSS style time_ago_in_words rails
I was wondering what would be the best solution for customising the rails helper: time_ago_in_words, so that I could do things like:
4
hours
ago
or what the…
Darcbar
- 888
- 1
- 8
- 25
0
votes
1 answer
Recursive function in helper method scoping issues
Ok so I'm playing around with a nested comments system on rails using Awesome nested set. I'm currently implementing a recursive function to get the nesting working (I know for performance this is terribly inefficient, but I just want this to work…
Msencenb
- 5,407
- 11
- 48
- 81
0
votes
1 answer
sharing private methods across controllers
Hey guys, I have two controllers, X and Y:
In X, I have a :before_filter for a private method, foo.
I also have the following statement at the top of controller X.
helper_method :foo
In controller Y, I have a :before_filter for a private method,…
deruse
- 2,731
- 7
- 37
- 59