Questions tagged [helpermethods]
86 questions
0
votes
2 answers
NoMethodError, undefined method 'bid'
Ive been trying to call a helper method from my controller on a rails object and i continue to get this error. Here is all my code.
class AuctionsController < ApplicationController
helper_method :bid
def bid
@auction =…

Clay McCullough
- 69
- 8
0
votes
1 answer
Only need simple_format when there are is new line \n
I have some strings that contain carriage return (new lines), and using the helper method simple_format works perfect for that.
Unfortunately though, now all strings get the wrapping tag and class defined with simple_format, and that creates…

Fellow Stranger
- 32,129
- 35
- 168
- 232
0
votes
2 answers
Check if a specific script is present from an helper/extension method in MVC C#
Is there a way to check in a helper/extension method if a certain script is present in a view?
My idea is to create a custom TextBoxFor() method where the focus is moved to the next input once the present one reach the maxLenght.

Bonomi
- 2,541
- 5
- 39
- 51
0
votes
2 answers
Executing ruby code from a view in rails
This code is executed from a view, and it works:
<% @metaTags = OpenGraph.fetch('http://www.someurl.com') || nil %>
<% if @metaTags != nil %>
postTitle = truncateStr('<%= @metaTags.title %>', 72);
<% end %>
I'd like to do the same but passing…

Mike
- 1,296
- 2
- 15
- 40
0
votes
1 answer
Use a helper method on a interpolated string
I am looking to see how I would set up my :notice to incorporate a helper method, at the moment I have this and get 'undefined method to_dollars':
notice: "Thank you for your payment of #{to_dollars(amount)}"
Controller
def create
@donation =…

Richlewis
- 15,070
- 37
- 122
- 283
0
votes
1 answer
Came across this code & I'm wondering why this static helper method is needed?
I did not write this code, All credit goes to the person that is hosting the link. So here is a link to the code and the guy who wrote it is listed on github also... Link -Github SourceCode-
Here is the method preview: (see class below)
//helper…

nckbrz
- 688
- 1
- 6
- 20
0
votes
1 answer
Helper method from application_controller not accessible from view
Application controller has a helper methods : current_user is accessible from all my views. But pro_user is completely inaccessible from my view.
def current_user
@current_user ||= User.find_by_auth_token( cookies[:auth_token]) if…

user2511030
- 515
- 1
- 4
- 14
0
votes
2 answers
Standalone helper_method checking for presence, e.g. @user.name if existent?
In the view I normally check for presence of a value like this:
<%= @user.name if @user.name.present? %>
Does it exist something shorter that understands my intention and not needing to repeat what I want to check? I'm looking for something like…

Fellow Stranger
- 32,129
- 35
- 168
- 232
0
votes
1 answer
Helper Method does not work in my Index Page, Star Rating Sytem
I've implemented a Star Rating System using this tutorial http://eighty-b.tumblr.com/post/1569674815/creating-an-ajaxified-star-rating-system-in-rails-3
The Ajax works perfectly and so do my methods on the BOOKS SHOW PAGE
But for some reason, my…

Serge Pedroza
- 2,160
- 3
- 28
- 41
0
votes
4 answers
Create a list of clickable links in a Helper module
A user has a set of saved links.
Each link has the properties address and text. These can be accessed like so:
@user.links.first.address
@user.links.first.text
How would I generate a list of a tags for all links that a user has saved in a helper…

Fellow Stranger
- 32,129
- 35
- 168
- 232
0
votes
1 answer
Send javascript variable to rails helper method
I have an array of video names, I want to grab a random video name from this array. But when I call a helper method to do all this, I get the same random number, and random video each time.
I believe this is because the helper method is only called…

Riveascore
- 1,724
- 4
- 26
- 46
0
votes
3 answers
generic helper to get ObjectResult that will match any given EntityObject
trying to make a generic SQL Query via a method that will fetch data i was making this code
public ObjectResult getUsersRes(string sqlStr, string ColNameAsfilter, string FiltersValue,string OrderByFilter="")
{
string…

Avia Afer
- 866
- 2
- 8
- 29
0
votes
1 answer
Cannot access helper method?
Here is a strange issue.
In my application helper, there is a method named test, and an other method named article_url. I have the article resource, and generate its url_helpers. In the test method, i call article_url, but it access the url_helper…

winterwhisper
- 13
- 3
0
votes
2 answers
Rails application - how to display an array or arrays
I have a homepage view in my rails app and I also have two types of content, articles and events. I'd like to have a partial on the homepage that displays the most recent articles and events together (mixed, like a news feed). Articles should be…

Arash Hadipanah
- 115
- 9
0
votes
1 answer
Serving an array of different content types in Rails
I have two content types, articles and events. I want to create a partial on my homepage to serve an array of both.
I was thinking of creating a helper method called latest_news, something like this
def latest_news(limit=12)
@articles =…

Arash Hadipanah
- 115
- 9