Displaying 20 results from an estimated 100000 matches similar to: "Using helpers in model?"
2009 Jan 06
1
How to access text helper and url helper methods in model
Hi,
I want to access TextHelper and UrlHelper methods in my model so how i
am able to access it ?
I was included following helper in my model but still it is not
working? also for accessing these helper method w need to give external
reference?
E.g.
class Xyz
include ActionView::Helpers::TextHelper
include ActionView::Helpers::UrlHelper
Also
2009 Sep 14
0
markdown call prompts "uninitialized constant ActionView::Helpers::TextHelper::Markdown" in upgraded application
Hey All,
I''m attempting to upgrade my app from rails 2.0.2 to 2.3.3. One bit that''s failing is this call here (in /views/projects/show.html.erb)
<%= markdown(@project.description) %>
That earns me a:
uninitialized constant ActionView::Helpers::TextHelper::Markdown
On that line.
I''m on a rebuilt machine (windows xp, ruby 1.8.6) so I thought it was a
2006 Jul 11
0
better way to include helpers into application controller/test_helper?
Right now, I have the following in my application controller - and a
simliar version is duplicated in test_helper. There must be a better
way to include common functionality like this that gets used across
layers? Maybe at the very least a way to include it at the class
level and instance level with one line?
# provide access to text helper at class level
def self.text_helper
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 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
2010 Jul 19
0
redcloth with rails3 and ruby 1.9.2
is redcloth working with rails3 and 1.9.2?
I don''t see it here - http://railsplugins.org/
redcloth 4.2.3 throws this exception when trying to use the method
textilize:
uninitialized constant ActionView::Helpers::TextHelper::RedCloth
I might need to use the 1.9.2.
can you guide me how to use the 1.9.2 version? (I assume i''ll have to
clone the repo but not sure what to do next).
2008 Oct 29
1
using text helper in a model class
Hi,
I have refactored my code and the previous function in my controller
help.truncate() doesn''t seems to work anymore in my model.
My model class is generating files and I''d like to use this text helper.
How can I fix that?
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are
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 Nov 04
0
Using Field Helpers to Edit a Related Model Object
Hello folks,
Here''s a question about creating an edit screen for a model and a
related model. On page 355 of the AWDWR book (printed page 464 of the
2nd edition pdf), there''s a little table showing how form parameters
map to the params object. One of them is:
user[address][city]=Wien
... maps to params as ...
{ :user => { :address => { :city =>
2007 Jan 16
2
Using view helpers in migrations?
I''m writing a bloggish/CMSish thing. I had been using simple_format,
but my users requested a rich editor, so I added TinyMCE.
Anyway, I was trying to migrate the existing content (since TinyMCE
assumes it''s reading HTML-formatted text), and realized that I
couldn''t call simple_format (or other helper methods) from Migrations.
Can someone enlighten me here?
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 Mar 01
0
TextHelpers in Controller?
I have a controller that saves info to the DB. It''s based on the AJAX
scaffolding code. All I want to do is add a simple_format() function to
it before I save a user-edited text field to the DB. TO convert line
returns to <br>s, etc.
@project_note = ProjectNote.new(params[:project_note])
@project_note.body = simple_format(@project_note.body)
Since this happens in a controller,
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
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
2006 May 15
0
Using rails form helpers for non model objects
Here''s a very simple tutorial that I wrote for using form helpers like
text_field or text_field_with_auto_complete for creating non model
attribute fields.
http://eugene.eggkeg.com/?p=8
--
Posted via http://www.ruby-forum.com/.
2011 Jan 23
2
RedCloth 4.1.1 vs. 4.2.3 - weird behaviour with notextile
For a community project I aim to combine RedCloth and Coderay and on doing
this, I might have found an issue with RedCloth.
I pushed a demo to Github:
https://github.com/markusproske/redcloth_coderay_demo
The index (http://localhost:3000/) demonstrates the issue.
In brief:
A page consist of textile. The textile contains @@@ruby somecode @@@
The textile is first feed into Coderay via a helper
2006 Mar 08
2
RJS - page object in helpers?
Hello,
I am using RJS and Edge Rails and I was wondering if the page object should
be available in helpers also.
For example if I have a helper function
def update_flash_messages
page.replace_html ''flash_messages'', (show_flash_messages :textilize => true)
page.visual_effect ''flash_messages'', :appear
end
and then in my RJS files I call
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.