Questions tagged [helpermethods]

86 questions
3
votes
1 answer

How to Pass ActiveRecord Objects as Parameters to Helper Methods in Rails

Many helper methods, such as redirect_to, link_to, and url_for, can take an ActiveRecord object as a parameter instead of a hash that specifies the controller and action. I've seen the parameter passed different ways in different documentation. It…
whiny_nil
  • 83
  • 2
  • 7
3
votes
1 answer

reflection with stacktrace / stackframe to get both methods name and parameters

while writing the question subject I came across some other allmost related post ...leading to MSDN http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.aspx but i couldn't manage to extract the bit of code i needed i just learnd…
LoneXcoder
  • 2,121
  • 6
  • 38
  • 76
2
votes
1 answer

Including Custom Helper Method in Ruby Gem

I've been attempting to add a helper method to my ruby gem for use with Rails 3. Here is an example of what I am attempting to achieve: module MyHelper def my_method render :text => "Hello World!" end end I've tried prepending MyHelper.rb…
user414381
2
votes
1 answer

Rails keeps changing my string "?" into "%3F"

Basicaly I just want to insert this + "?direction=desc" in helper method. But once it parses it comes out like this.. /organizations/search?order_by=contactable%3Fdirection%3Ddesc Anyone know a way around this? My Helper Method: def…
Trip
  • 26,756
  • 46
  • 158
  • 277
2
votes
1 answer

Display time remaining with distance_of_time_in_words

So i want item to display to remaining on Items after 7 days the item will be deleted. ive tried <%= distance_of_time_in_words(item.created_at, item.created_at + 7.days) %> but all i get is "7 Days" on all items. Can anyone simply how this helper…
Miguel Angel Quintana
  • 1,371
  • 2
  • 9
  • 12
2
votes
2 answers

Interface Segregation Principle and Convenience/Helper Methods

How does the Interface Segregation Principle apply to convenience/helper methods? For instance: I want to create an interface that represents business partners. The bare minimum that I would need would be a setter and a getter method that would…
2
votes
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
  • 87
  • 1
  • 7
2
votes
1 answer

rails “undefined method” when invoking a helper method from the view

I want to get the gender of a person from a helper method like so: sportists_helper.rb def sportists_gender gender = self.gender if gender == "1" "Male" elsif gender == "2" "Female" end end and then print it out in a view: <%=…
Xeen
  • 6,955
  • 16
  • 60
  • 111
2
votes
1 answer

How do I call a method inside ApplicationHelper from my Model?

# application_helper.rb def do_some_stuff ... end # my_model.rb def my_model_method # I want to call the method "do_some_stuff" here, how exactly? end Obviously, I can't just call do_some_stuff, since it would tell me that the model does…
TomDogg
  • 3,803
  • 5
  • 33
  • 60
2
votes
2 answers

Rails distance_of_time_in_words_to_now options

I'm guessing I need to create a helper method to achieve this, but essentially I'd like to use distance_of_time_in_words_to_now to display the time between a datetime field's data and now, but in more specific words. For instance, if it's 3 days it…
Trevan Hetzel
  • 1,371
  • 7
  • 21
  • 42
2
votes
0 answers

Render 3-column table of checkboxes using Helper methods and editor template

The code below is taken from the instructors Edit view of this tutorial: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/updating-related-data-with-the-entity-framework-in-an-asp-net-mvc-application
user1405195
  • 1,667
  • 4
  • 22
  • 35
1
vote
1 answer

Keeping the helper methods in the same scope as of main_operation_methods reduces readability

I have a MineSweeper program, where I am facing a scenario similar to., Where is my problem? class operation{ /*(Each operation needs all the datas.)*/ public mainOperation(){ // user can call this…
Muthu Ganapathy Nathan
  • 3,199
  • 16
  • 47
  • 77
1
vote
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,851
  • 7
  • 40
  • 60
1
vote
2 answers

ruby "first" helper method?

i have the following file member.html.erb:
    <%@members.each do |member|%>
  • <%=member.name%>
  • <%end%>
i want to add the "first" class to the first li that will be generated…
Ran
  • 3,455
  • 12
  • 47
  • 60
1
vote
3 answers

c# Method not working as expected Address book project

I'm new to c# and working on my first project - a console app. I am having some trouble understanding why my code will not return false when an entry in the address book already exists. The following methods are all part of the AddressBook class…
Nibble15
  • 17
  • 1
  • 7