Questions tagged [helpermethods]
86 questions
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,675
- 11
- 52
- 84
0
votes
0 answers
Produce a truth table set of n values, but I have only one problem
def make_tt_ins(n):
if n == 0:
return []
elif n == 1:
return [False, True]
else:
prev_set = make_tt_ins(n - 1)
full_set = cross_multiply(prev_set, [False, True])
return full_set
def cross_multiply(s1, s2):
…
0
votes
2 answers
output of the rails select_tag
i'm new to rails and am having difficulty figuring out how to use the output of a select form in rails 3. the following is my select tag:
<%= form_for(:order, :url => {:action => 'create_order'}) do |f| %>
<%= select_tag(…

Andrew
- 171
- 1
- 10
0
votes
0 answers
laravel accesing resource folder by helper method+ routing
Edit : Solved ,as DigitalDrifter siggested , npm run dev will automatically move all assets deom resouece to public . so dont waste time on resource folder access .
as per laravel docs ,I run command
php artisan ui vue --auth
to create auth…

Neeraj Verma
- 2,174
- 6
- 30
- 51
0
votes
1 answer
Problem with escaping HTML characters in Rails 3
I use foo helper function in my view:
<%= foo ["hello", "stack", "overflow"] %>
When foo is defined like this:
def foo(arr)
result = ''
arr.each do |a|
result += content_tag(:div, a)
end
result
end
The page…

Misha Moroshko
- 166,356
- 226
- 505
- 746
0
votes
3 answers
How do I work with Rails 3 cookies and helpers?
I created a user and stored the id in a permanent cookie:
def save_user_id_cookie
cookies.permanent.signed[:user_id] = @user_id
end
Here is a link.
and then try to access it:
helper_method :current_user
private
def current_user
@current_user =…

Alex
- 690
- 1
- 9
- 29
0
votes
0 answers
Meteor and MongoDB rerun helpers function
I'm working on a project to manage the attendance of students in school.
The frontend runs with meteor. It displays the presence of all students from one class for the current day. The user (teacher) can switch the days back and forth, to make some…

Bejlem
- 1
- 6
0
votes
3 answers
Using image_url helper in model
I'm trying to use the image_url helper in my model. I also have an image_url property on the model(can't be changed). When I call image_url, the helper method it appears to be calling the method on the model. I get the error wrong number of…

Antarr Byrd
- 24,863
- 33
- 100
- 188
0
votes
1 answer
How do I define a variable that all my views can access?
I have a Rails 5 web app (almost). I want to include an attribute on all my views. I read somewhere that the way to do this was to define a helper method in my application controller, so I defined
class ApplicationController <…
user7055375
0
votes
2 answers
Is there a benefit to create a helper method for only one use?
I notice in Rails tutorials sometimes the authors make helper methods that are only used one time. This strikes me as ridiculous but while learning ActionCable I noticed that DHH did the same thing in his introduction for ActionCable 2 years ago. So…

Steve Carey
- 2,876
- 23
- 34
0
votes
5 answers
Helper Method detect post - comment from user
I'm trying to create a helper method that will display {user.name} has no submitted posts." on the profile show view of user if they haven't yet submitted any posts and display the number posts they have . currently on my show view i have <%=…

Miguel Angel Quintana
- 1,371
- 2
- 9
- 12
0
votes
2 answers
Retrieve method for a polymorphic, has_one and scoped association
Hi this is somewhat it trivial but I can't for the life of me figure out where to make the adjustments.
I have a LoanApplication model and a transfer model like this:
class LoanApplication < ActiveRecord::Base
before_save :populate_guid
…

Ghost
- 145
- 1
- 10
0
votes
1 answer
Ruby on rails: previous url helper for entire application
Is there an easy way to write a helper method to always update the previously visited url in the session. I have tried the method below but the url saved is always the current one. I would like to be able to use this helper in all my controllers for…

Mais
- 29
- 7
0
votes
0 answers
Why controllers action doesn't send json data in response
I learn ASP.NET MVC and have some issue.
I create two links by ajax helper method in view. They send mailsType argument and response json data. Here is the code of links and AjaxOptions object

iplot
- 3
- 2
0
votes
1 answer
Rails: How to determine where a helper methods 'points'
Near the start of this page...
http://guides.rubyonrails.org/routing.html
... there's an example involving @patient (section 1.2).
I'd like to know how to determine where the following line points:
<%= link_to 'Patient Record',…

moosefetcher
- 1,841
- 2
- 23
- 39