Displaying 20 results from an estimated 20000 matches similar to: "Cannot extend class in Application Helper"
2011 Apr 08
5
How to extend a helper using plugin?
Hello,
I''m facing this problem while trying to extend the parse_redmine_links
helper method in Redmine-1.1.0 (Rails-2.3.5) from my plugin.
My idea is to use alias_method_chain so the extended version could
call the original version and adjust the result to it''s liking.
Anything I''ve tried so far exposes this behavior: the first render of
a page uses the extended
2008 Mar 19
3
ApplicationHelper
When working with views, I use instance methods of ApplicationHelper:
# app/helpers/application_helper.rb:
module ApplicationHelper
def distribute(total, min, cutof, list)
[1,2,3]
end
end
# app/views/planner/_mta_colors.rhtml:
<td>
<%
...
dist = distribute(total_v_px, 4, 0, colors.collect{|color| color[1]})
...
%>
So to test the distribute method in ApplicationHelper, I have
2007 Jul 31
11
helper spec not finding rails core helpers
Hi,
My helper specs were going ok until I added a call to a rails
DateHelper method in one of my helpers
http://api.rubyonrails.com/classes/ActionView/Helpers/
DateHelper.html#M000574
The helper runs fine from my view templates, just dies in the spec test.
I boiled my question down to a simple (not too useful) example. I''m
not sure what I''m missing.
#
2008 Oct 31
10
Strange dependency error after going Ruby1.8.6, Rails 2.1.0 -> Ruby1.8.7, Rails 2.1.2
Hi,
I''m getting an error I just can''t find any cause for.
The error is "A copy of ApplicationHelper has been removed from the
module tree but is still active!" and gets thrown
in a Template that uses a method defined in my ApplicationHelper. The
error occurs only in development mode.
The error did not occur before my switch to Ruby 1.8.7 and Rails 2.1.2
minutes ago.
I
2008 Mar 12
1
Testing helper methods in rspec
This is perhaps a naive question, but what is the recommended manner of
testing a helper method in rspec? I have created a simple string manipulation
function and I want to write some tests for it. It it were a script then I
would just add if __FILE__ == $0 and add the tests below that but I do not
feel that this is the best way to handle a rails helper.
The code (I said it was simple) :
2008 Aug 08
2
template.expect_render fails when partial is rendered from a helper
My spec;
describe ''subnav rendering while logged in'' do
before do
template.stub!(:logged_in?).and_return(true)
template.stub!
(:current_profile).at_least(:once).and_return(mock_profile)
end
def do_render
render "/homepages/show.html.erb"
end
it "should render the logged in partial for homepages" do
2006 Mar 25
3
Rails Plugins: Why to register your own functionality with send()?
Hi there,
I have seen in the file column plugin (
http://www.kanthak.net/opensource/file_column/) from Sebastian Kanthak or
David''s acts_as_taggable plugin that to register my functionality I need to
do something like this:
ApplicationHelper.send(:include, InPlaceEditAssociations)
I am wondering why not:
(a)
module ApplicationHelper
include InPlaceEditAssociatons
end
or:
(b)
2006 Feb 11
7
Menu Helper
Hi all,
I''m trying to add a common menu to all pages in my application. It is
just a set of links I want to display. I''m having trouble deciding
where to put the code. Below is what I''ve tried to get out of the "Four
Days on Rails" tutorial but no luck. Any help would be appreciated. Am
I on the right track?
Thanks,
Sam
2006 Sep 29
2
ApplicationHelper is not a parent of SomeHelper?
i have:
# file application_helper.rb
module ApplicationHelper
def load_components
@right_sidebar = ''some stuffs''
end
end
# file user_public/blog_helper.rb
module UserPublic::BlogHelper
def load_components
ApplicationHelper.load_components
@right_sidebar += ''{blog archive}''
end
end
the problem is, i want to load the
2007 Jul 24
4
spec''ing helpers that use controller
Hi all,
I''m in the process of creating rspecs for my helpers. One of the
helpers in app/helpers/application_helper.rb looks like this:
def page_name
@page_name || "Define @page_name in
#{controller.controller_name}::#{controller.action_name}"
end
The rspec is simply:
it "should something" do
page_name
end
2006 Sep 03
2
Undefined method "xxx" of a model when calling a helper
Hi all
I''m creating a shop page. I have a cart model that looks like the
following:
class Cart
attr_reader :line_items
def get_line_item id
@line_items.each do |l|
return l if l.id == id
end
end
def initialize
@line_items = []
end
def empty!
initialize
end
def empty?
return true if @line_items.empty?
false
end
end
And I have some
2005 Dec 19
3
Trying to make an app helper
Any ideas with fixing this? Doesn''t work properly, although it doesn''t
throw any runtime errors.
# Methods added to this helper will be available to all templates in the
application.
module ApplicationHelper
def options_for_months(selected_month)
2007 Aug 27
2
issue with edge rails and urls
I just switched our project over to Edge Rails, and I''m running into
this problem with all of my helper methods that call _url methods:
NoMethodError in ''ApplicationHelper home_link should generate a valid
home link when User.current and Profile.current is not set''
You have a nil object when you didn''t expect it!
You might have expected an instance of
2006 Feb 27
0
application helper and tri-state images
I''ve come up with a very hackish way of creating a tri-state image
navbar. I don''t like it but it works pretty well. I would love to know
the ''rails'' way of doing this or even just a suggestion. Here''s my
helper.
module ApplicationHelper
# we use this function to create the tri-state image with rollovers
# todo I need to use a good css trick
2009 Apr 12
4
Can't get an Array function to be visible inside ApplicationHelper
Folks,
I seem to be missing something basic here.
I am trying to call a function from my application layout that will
return me a hash of the roles for the user currently signed in. Here
is the simplified code I have in ApplicationHelper module
class Array
def to_h
Hash[*enum_with_index.to_a.flatten]
end
end
def get_cur_user_roles
["school_admin",
2006 Feb 09
4
Login_Engine: trouble configuring
Hi Guys,
I''m having some trouble getting login_engine to work. I''ve followed the
steps in the README file to the letter (I think) with the exception of
the Mailer stuff and cannot get my application to run. Heres what I have;
module ApplicationHelper
include login_engine
end
#####################################
require ''login_engine''
class
2006 May 13
1
undefined method `strftime'', being called from a partial.
Hi,
I''m having an issue with calling a function that I''ve defined in
ApplicationHelper called format_time:
module ApplicationHelper
def format_time(time)
time.strftime("%a %b %d, %I:%M%p")
end
end
I use this function in my views to format the Time.now that I would have
stored in my tables as a DATETIME. I''m able to use this function, without
any
2008 Jan 24
3
Help to spec a rails helper method that uses content_for
Hi guys,
I am a Rspec newbie and am having problems creating a spec for a RoR helper
method.
I have in fact already implemented the helper method and am trying to create
retrospective specs. I know its the wrong way to do it but I am still
learning Rspec.
In my view I have a call to a helper method.
<% body_class "users" %>
which sets a CSS class declaration in the content_for
2006 May 29
2
How to use script/runner
I''ve read the wiki and Agile and can''t find the answer.
When using script/runner I''ve gotten simple model functions similar to
the -help example to run:
$script/runner ''puts Vendor.find(1).name3''
where Vendor is a model.
However when I try to run a function in a controller it doesn''t work:
$script/runner ''puts
2006 Jan 17
6
link_to or helper to generate a javascript:history.back() ?
Hello,
There is an link_to option or an helper that generate a link like :
<a href="javascript:history.back()">Back</a>
Thanks