Questions tagged [helpermethods]

86 questions
0
votes
1 answer

Issue with helper_methods from views rails

I have a very frustrating issue. I can't call any helper method from my views in rails.This is what I have: ApplicationController.rb class ApplicationController < ActionController::Base protect_from_forgery def current_user …
0
votes
1 answer

Generating a google chart with array from helper function in rails

Why does this work: var data_array = [["name", "value"], ["osnadosd", 25]] var data = new google.visualization.arrayToDataTable(data_array, false); And this doesn't: var data_array = <%= make_a_chart(@db_call.results) %> var data =…
delisdeli
  • 839
  • 9
  • 20
0
votes
2 answers

Helper methods in Controller

I have a helper module: module SessionsHelper @current_user @current_session def current_user @current_user = User.find(cookies[:user_id]) if(cookies[:user_id]) end def current_session @current_session =…
mabounassif
  • 2,311
  • 6
  • 29
  • 46
0
votes
2 answers

Return Array in a helper method

Why can't I return an array in a helper method? def childrenOf(a) @children = Post.find_by_parent_id(a.id) return @children end Thanks in advance
Sammy
  • 885
  • 3
  • 13
  • 32
0
votes
4 answers

How to manipulate the properties of a user-defined class on runtime?

I have a huge user-defined class with lots of properties and some of them has to be set with a certain value. To be more specific, all the public properties with the type of string in this user-defined class have to be "emptied" at the end of…
Bedir Yilmaz
  • 3,823
  • 5
  • 34
  • 54
0
votes
2 answers

Rails helper method execution before call

The @test variable I have is getting evaluated before I want it to. Here's what I intend: I have a button (link right now) with a variable shown next to it. The value should say "blank" when the page is initially loaded. When I click that button,…
Jack
  • 5,264
  • 7
  • 34
  • 43
0
votes
1 answer

How to stop a helper method from applying to a specific controller?

I have a helper_method that allows links to escape from a subdomain. However it is impacting my videos_controller, as it essentially seems to negate the 'current_event' method when not in the events controlller. I've tried several dozen different…
jfdimark
  • 2,239
  • 1
  • 14
  • 27
0
votes
1 answer

checkboxtag in forms

Im looking for the following thing: an array of all users (only 6 in this case) with a checkbox in front of their name, resulting in a list of selectable players for the game. Current code: <%= form_for @game, url: games_path, :method => "post" do…
Flame
  • 6,663
  • 3
  • 33
  • 53
0
votes
2 answers

How to call the ApplicationController helper method in model? RoR

Guys I've a helper method in ApplicationController as follows class ApplicationController < ActionController::Base helper_method :current_user end And I want to call it in my model (say Project) as follows: class Project < ActiveRecord::Base …
-1
votes
1 answer

Reducing redundancy in methods

I have an Enum, with an abstract method, and every case in the enum implements this method. However, in each implementation the variable declarations are always the same, and so I end up with lots of redundancy. public FSA next(Player targetPlayer,…
Hdot
  • 543
  • 1
  • 4
  • 15
-2
votes
2 answers

Objects in Java is printing out junk

My program is a simple program that involves the use of objects. There are no errors the only problem is that my program is printing out junk. After it asked the user for it name, age , and gender. Down below are two sets of programs. The first one…
1 2 3 4 5
6