Displaying 20 results from an estimated 8000 matches similar to: "How to access text helper and url helper methods in model"
2009 Jun 11
4
Using view helpers and route helpers in a model
Hi there,
I am trying to get something working and its driving me crazy. I have
been looking around for solutions to getting view helpers working in
models and for the most part I find this solution.
Add the following in the model you want to use them in
include ActionView::Helpers::UrlHelper
include ActionController::UrlWriter
However, when I try something like
2011 Apr 19
1
RSpec/Webrat Checking output is properly escaped
I want to test that the JSON response from a create action is
sanitized properly, but rspec or webrat appears to be parsing the
output into proper HTML chars instead of escaped characters. I have
verified that it escapes properly in the regular browser json
response.
The relevant RSpec test code is:
include ActionView::Helpers::TextHelper
include ActionView::Helpers::UrlHelper
it
2006 May 15
1
Simple: How to use TextHelper in a controller
I''m having trouble succesfully getting access to the
ActionView::Helpers::TextHelper.strip_tags
method from one of my controllers.
If I try to call it directly using
ActionView::Helpers::TextHelper.strip_tags
I get
undefined method `strip_tags'' for ActionView::Helpers::TextHelper:Module
What is the preferred way to make ActionView helpers available to a
descendant of
2006 May 21
6
Is there a way to call helper methods in a controller?
Hi,
Is there a way to call helper methods in a controller?
I want to do something like this in my controller
Class MyController < Action....
def my_method
string = link_to "some_url", :controller => "home", :action => "command"
end
end
link_to is an ActionView helper method and it seems that I couldn''t access
the method in the controller
2006 Jan 12
3
url_for in tests
Hi there,
I''ve added an extra bunch of testing features for doing in-browser
testing with Selenium, and am having quite a time figuring out how to
use url_for with having a controller object present. I''ve tried using
ActionController::Base.url_for and
ActionView::Helpers::UrlHelper.url_for but haven''t been able to get
something that works.
What I want to be able
2006 Aug 10
3
Want to use a view helper (TextHelper) in a model class
I have a model that deals with HTML and I want to use the
text_helper.sanitize method to strip the HTML of Javascript.
However, it doesn''t appear that I can get easy access to the text_helper
methods from within a model.
Anyone have any suggestions for how to do this?
In general, I think that there are some ActionView helpers which are
generic enough to want to use in a model class.
2006 May 16
3
Best way to handle namespace collisions?
All,
I have a little namespace collision here. I am trying to use both
RubyfulSoup (an HTML parser - which I highly recommend by the way) and
the ActionView::Helpers::TextHelper class. Within the TextHelper class,
there''s an attempt to create a new "Tag" object. However, Tag is also
defined in the RubyfulSoup gem and it is _this_ Tag class whose
initialize method is
2009 Jan 01
2
Ruby on rails API website suggestion
I would like to request a feature.. like: http://rubyonrails.org/function
and it
will search inside http://api.rubyonrails.org for the function and
show it.
Like PHP has.. http://php.net/basename
Example: http://rubyonrails.org/truncate and it will points to
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001541
That woul be cool.
Thanks
2009 Jan 01
2
Ruby on rails API website suggestion
I would like to request a feature.. like: http://rubyonrails.org/function
and it
will search inside http://api.rubyonrails.org for the function and
show it.
Like PHP has.. http://php.net/basename
Example: http://rubyonrails.org/truncate and it will points to
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#M001541
That woul be cool.
Thanks
2006 Jan 03
7
link_to an external url ?
Simple question. Is it possible to generate a link like
<a href="http://www.google.com" target="_blank" >google</a>
with the link_to function ?
Thanks
2010 Sep 23
1
Patch to fix docs for auto_link
Hi I''ve contributed a patch which fixes an incorrect example in the
documentation for auto_link in ActionView::Helpers::TextHelper.
The example uses truncate in the old style of tuncate(text, length)
which no longer works, so I''ve patched it to use the new
tuncate(text, :length => n) style.
2007 Oct 03
2
Providing HTML in an error message generated by validation
All,
I have some validation that I''m doing in a model.
As part of the error message, I would like to provide an HTML link.
What is the best approach to handling this?
APPROACH 1: One way is to
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::TagHelper
in my model so that I can use link_to to generate my link (obv. I could
hard code HTML as well).
But anyway that
2006 Feb 10
2
How do I test actionview helpers in the console?
I would like to see the output of actionview helper methods, to be able
to play with it.
When I do the following in the console:
collection_select("job", "client_id" , @clients, "id", "name")
I get:
NoMethodError: undefined method `collection_select'' for
#<Object:0xb7cf1970>
I''d like to get something like:
<select
2006 Jan 04
2
Navigation Helper
I am attempting to integrate a main navigation section into my web
application. Naturally the easiest and DRY way to do this would be to
either include it in a layout, or as a partial. The only problem is
that I want the link for the current page to have its own css id
("current"). The only way I can think to accomplish this is to just
include the navigation in every page, but this is
2006 Feb 07
0
scope problems testing a helper method that calls link_to()
We''ve been having problems writing functional tests for helper methods
that rely on ActionView methods. Here''s a specific example.
In application_helper.rb I''ve got a method called ''party_link()ยจ:
def party_link(party)
link_to party.full_name, { :controller => ''contacts'',
:action =>
2009 Feb 24
2
Displaying line breaks & paragraphs using 'simple_format' ?
Hi there,
I need to:
1. STORE a text of the below format in a (MySQL) database (using a
''textarea''), and then
2. RETRIEVE & DISPLAY it in exactly the same format (meaning: keeping
all paragraphs/line breaks).
The intended text format looks like this:
***
Blah blahblah blah blah blahblah blah blah
blahblah blah blah blahblah blah, blah
blahblah. <- NEW
2006 May 02
6
Is there a link_to ''external url''?
I''ve checked the Rails documentation but find no mention of link_to
''external url'' or equivalent. Does rails have a built in method to do
this?
thanks
-Lindsay
--
Posted via http://www.ruby-forum.com/.
2008 Jun 15
11
[PATCH] helper to create fb css stylized table
I attached a rails helper implementation of the fb_table described here:
http://wiki.developers.facebook.com/index.php/Facebook_Styles
I included testing and comments. I hope you find it useful.
Curiously, it''s really a small extension of FBML.
Richard
-------------- next part --------------
Index: test/rails_integration_test.rb
2008 Feb 20
1
link_to weirdness, related to namespace?
Hi,
In my app/views/admin/clieint/_searchresults.rhtml partial, I have ...
<% for user in @users %>
<tr>
<td><%=h user.ship_to_first_name %></td>
<td><%=h user.ship_to_last_name %></td>
<td><%=h user.email %></td>
<td align="center"><%= link_to ''Show'', {:action =>
2006 Jan 18
5
redirect_to with an anchor, how ?
Hello,
I try this :
redirect_to :action => ''infos'' , :id => params[:id] , :show => "comments#a"
i want this : .../infos/15?show=comments#a
but I have this : .../infos/15?show=comments%23a
Someone could tell me how generate an anchor link ?
Thanks