softwareengineer 99
2006-Feb-09 00:58 UTC
[Rails] Very weird issue - Function not being recognized in template?
I created a function before going to dinner and placed it in application.rb.
Something like:
def at_home
...
end
Then I called it from my .rhtml file like:
<% if at_home %>
.....
<% end %>
The function was working perfectly (I tested it before leaving). When I got
back I keep getting
undefined local variable or method `at_home'' for
#<#<Class:0xb6e92960>:0xb6e92898
The weird thing is that I am calling the same function in my controller and it
does not raise this error there?
The only other thing happened is that I rebooted the server.
So my question is does any one have an idea why something like this would
happen? Why is my function in application.rb being recognized by the controller
but not being recognized by my template
Thoughts and ideas are greatly appreciated.
Thanks
Frank
---------------------------------
Brings words and photos together (easily) with
PhotoMail - it''s free and works with Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060209/178493e7/attachment.html
softwareengineer 99
2006-Feb-09 01:07 UTC
[Rails] Very weird issue - Function not being recognized in template? Solved
I solved it. Apparently it seems like if I use a function in controller and a
template I need to put the function in both application_helper and
application.rb.
Is there any way to avoid the duplication? Can a function be stored in a file
and be accessible to both templates and the controllers?
Thanks
Frank
softwareengineer 99 <softwareengineer99@yahoo.com> wrote: I created a
function before going to dinner and placed it in application.rb. Something like:
def at_home
...
end
Then I called it from my .rhtml file like:
<% if at_home %>
.....
<% end %>
The function was working perfectly (I tested it before leaving). When I got
back I keep getting
undefined local variable or method `at_home'' for
#<#<Class:0xb6e92960>:0xb6e92898
The weird thing is that I am calling the same function in my controller and it
does not raise this error there?
The only other thing happened is that I rebooted the server.
So my question is does any one have an idea why something like this would
happen? Why is my function in application.rb being recognized by the controller
but not being recognized by my template
Thoughts and ideas are greatly appreciated.
Thanks
Frank
---------------------------------
Brings words and photos together (easily) with
PhotoMail - it''s free and works with Yahoo!
Mail._______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
---------------------------------
Brings words and photos together (easily) with
PhotoMail - it''s free and works with Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060209/144f15d4/attachment.html
Craig White
2006-Feb-09 01:14 UTC
[Rails] Very weird issue - Function not being recognized in template?
On Wed, 2006-02-08 at 16:58 -0800, softwareengineer 99 wrote:> I created a function before going to dinner and placed it in > application.rb. Something like: > > def at_home > ... > end > > Then I called it from my .rhtml file like: > > <% if at_home %> > ..... > <% end %> > > The function was working perfectly (I tested it before leaving). When > I got back I keep getting > > undefined local variable or method `at_home'' for #<#<Class:0xb6e92960>:0xb6e92898 > > The weird thing is that I am calling the same function in my controller and it does not raise this error there? > > The only other thing happened is that I rebooted the server. > > So my question is does any one have an idea why something like this would happen? Why is my function in application.rb being recognized by the controller but not being recognized by my template > Thoughts and ideas are greatly appreciated. >---- you are gonna have to learn to clear you cache on your web browser frequently when developing stuff. When you change stuff and the web browser is still running from cache...you won''t notice that something broke until later. Shift <click - refresh> works on most browsers. Craig