Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View helpers in rabl template throws 'undefined method' if used with gon #26

Closed
arnabc opened this issue Mar 5, 2012 · 7 comments
Closed

Comments

@arnabc
Copy link

arnabc commented Mar 5, 2012

My rabl templates are working fine if I use it outside gon for example as a response to XHR requests, but if I use the same template with gon it throws error in view helper methods used in the rabl templates. In Rabl, using Rails view helpers are allowed, so it seems that gon might be causing some issue in there, is it an issue with the view context ?

Here's my sample rable template:

attributes :id, :name, :created_at
node(:time_ago) { |m| distance_of_time_in_words(m.created_at, Time.now) }

There seems to be an issue filed in the Rabl repository related to this problem:
nesquena/rabl#147

Thanks,
Arnab

@gazay
Copy link
Owner

gazay commented Apr 17, 2012

Hello! Sorry for big delay, I did whole refactoring of gon this month. So I fixed this problem with including ActionView::Helpers into Rails::Engine. Now it's only in my refactoring branch - 7a4f50f
But soon I plan to merge it in master. What do you think? I checked that this including not affects Rabl functionality by running Rabl's specs with included helpers.

@gazay gazay closed this as completed Apr 17, 2012
@mull
Copy link

mull commented Aug 1, 2013

Using Rabl 0.8.6 (latest stable) I still have this problem. Is this issue really solved?

child :whatever do 
  [root_url]
end

Throws "undefined method root_url for Rabl::Engine"

@mull
Copy link

mull commented Aug 1, 2013

Sorry.. I should check what repository I am in! :D

@lulalala
Copy link

lulalala commented Aug 8, 2013

@mull may I ask how you solved it (I am having the same issue)

@mull
Copy link

mull commented Aug 11, 2013

@lulalala I can't quite remember what I changed unfortunately, I know I switched over to RablRails and then back to Rails.. heh! Sorry I can't be of any help.

@asumaran
Copy link

I'm getting the same error in the same case using rabl with gon in Rails

undefined local variable or method `this_time' for #Rabl::Engine:0x007febee9f13c0

this_time is located in the application_helper.rb file. any workaround for this?

Update:

I solved including the helper in the controller
include ApplicationHelper
and now everything is working fine

@askl56
Copy link

askl56 commented Apr 26, 2017

Bumping this thread to see if there is any update on it? @gazay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants