I'm writing a webapp in Ruby on Rails 3. Rails 3 automatically escapes any potentially-bad strings, which is generally a good thing, but means if you assemble HTML yourself, you have to call html_safe on it.
I have a Card model, which has several text fields, the contents of which are not trusted (may contain evil HTML or script). I hav...
I'm using CakePHP 1.3, and trying to make a simple message posting board with ajax. I'm trying to use the Js helper to submit a form on the index page, then refresh the message board's div to include the new message. This is all on a single page.
I have previously posted on this, but I wanted to rephrase the question and include some u...
Is it possible or How can i give a type to a FlashMessage in Zend?
For example
/* This is a "Success" message */
$this -> _helper -> FlashMessenger('You are successfully created a post.');
/* This is an "Error" message */
$this -> _helper -> FlashMessenger('There is an error while creating post.');
/* This is just a "Notification" ...
If a project is running Rails 2.2.2, and it uses controller.helper and the helper is not defined, then how can it be solved? (this is for the Facebooker2 gem http://github.com/mmangino/facebooker2)
details:
error shown:
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
Exiting
/Library/
Ruby/
Gems/1.8/gems/facebooker2-...
I think in newer versions of Rails, there are ways to say, "share these methods between controllers and views" using something like
controller.helper
controller.helper_method
(I am not sure if they are). But what if these methods are missing in older versions of Rails? How can you tell Rails to share methods between controllers and...
I have a method in my application helper that is meant to deactivate a task in my database.
Application helper:
def link_to_destroy_task(task_id)
Task.find(task_id).deactivate
end
Model:
def self.deactivate()
update_attribute(:active, false)
end
View:
<ol id="tasks">
<% @Tasks.each do |task| %>
<%content_tag_for...
I'm trying to call sanitize within a controller. Here's what I tried:
class FooController < ApplicationController
include ActionView::Helpers::SanitizeHelper
# ...
end
However, I'm getting this error:
undefined method `white_list_sanitizer' for FooController:Class
I searched around and people recommended switching the include l...
I was able to find some docs in apidoc.com but can't tell what exactly helper does.
helper_method seems more straight forward: to make some or all of the controller's methods available for use to the View. What about helper? Is it to do the other way around: import helper methods in a file or in a Module? (Maybe the name helper and h...
Hi,
I have a MySQL DATETIME field that holds the date of birth of a user. I want to use that date to display the age the user in years.
Is there a method of the Time core helper to do this?
Also, why when you add a DATETIME field to a form in Cake does it not let you select a date less than 1990?
Thanks,
Jonesy
...
I wish to encode my HTML sent to the browser. In my .ASPX pages I can use the <%: %> syntax. In a HTML helper of mine I try...
public static string Image(this HtmlHelper helper, string imageName, string altText)
{
return helper.Encode(String.Format("<image src='/images/{0}' alt='{1}' />", imageName, altText));
}
...
i have two view helper
module Admin::CategoriesHelper
def test
return "a"
end
module CategoriesHelper
def test
return "b"
end
i invoke test method in views/admin/categories/index.html.erb
====================================================================
if i use Admin::CategoriesHelper.test it will...