helpers

Test if a word is singular or plural in Ruby on Rails

Quick question. How can I test a word to see if it is singular or plural? I'd really like: test_singularity('word') # => true test_singularity('words') # => false I bet rails is capable! Thanks. ...

Help with rails collection select

I need to add different values for each option tag in my collection_select cause Im trying to use this jquery plugin.... How do I do that? Heres my collection select code <%= e.collection_select(:id,State.all,:id,:name) %> The output should be something like <select name="state[id]" id="state_id" class="selectable"> <option value=""...

Generate full url to javascript in rails (similar to javascript_path, but url)

Hi, How is it possible to generate an absolute link to the javascript file. I assume there should be something like the one below (which unfortunately does not seem to be available): javascript_url 'main' # -> 'http://localhost:3000/javascripts/main.js' instead of: javascript_path 'main' # -> '/javascripts/main.js' I need the a...

Using link_to in a class in a Rails helper

I have a rails helper using the structore below, but when I use it I get the message undefined method 'link_to' The helper is arranged as: module MyHelper class Facet def render_for_search link_to("Value", params) end end class FacetList attr_accessor :facets def initialize #Create facets end...

Embedding persistent login form Zend

I've seen this question asked already - but none of the answers really gelled for me, so I'm asking again: I want to embed a persistent login form (which will change into a nav bar if logged in) in the header bar for a site. Effectively, I want to be able to inject some controller logic into the layout. After much research, I can see se...

How to implement a helper in Symfony 1.4?

I'd like to create my own helper but can't find any help on Google for Symfony 1.4/Doctrine. I guess it has something to do with creating a myClassHelper.class.php in lib/helpers/ or something, but I don't know what to implement, or if specific methods have to be overridden. Any help would be appreciated! ...

Getting a jqgrid action helper to work

Hi After a few searches I came across a jqgrid action helper that I could include into my Zend MVC. However after downloading the source and trying to use it I get this error Fatal error: Call to a member function getActionController() on a non-object in ..... \Controller\Action\HelperBroker.php on line 299 Here is an excerpt of the ...

Help with asp.net mvc and Select List Dropdown

I want to build this dropdowns with these specific attributes.. How can I do this? Im using LinqToSql. Each Company has employees <select name="companies" id="companies" class="selectable"> <option value="">-- select --</option> <option value="1" title="company1">Company1</option> <option value="2" title="company2">company2<...

When building a datagrid helper, how do you access the new data annotation attributes using Reflection?

Hi, So I've eagerly added the System.ComponentModel.DataAnnotations namespace to my model. I've added things such as: [Required] [DisplayName("First Name")] public string first_name {get;set;} I really like these attributes because they save me from having to write custom T4 and/or modify views heavily. This way, I can regenerate a...

How do I use a custom helper method from a model in Rails?

There is a helper method in my custom helper module EntriesHelper that I need to use from inside a model. I watched the Railscasts episode Helpers Outside Views and learned about ActionController::Base.helpers, but this only gives you access to the built-in helpers. I don't want to simply include EntriesHelper in the model because of nam...

Cakephp FormHelper not outputting "<form>" tags

Hi, So I have a users controller with an action called "selfView" it looks like this: (*users_controller.php*) function selfView() { $user = $this->User->find('first', array('conditions' => array('User.id' => $this->Auth->user('id')))); $formms = $this->Form->find('all', array('fields' => array('Form.id', 'Form.name'), 'recursive' ...

Using Rails form helpers on non-existent methods

Normally, when using form helpers in Rails, each field directly correlates to a method on the appropriate object. However, I have a form (user signup) that needs to include fields that are not part of the user model itself (for instance, card details) but need to appear. How can I build the form so that I can get the necessary fields, ...

Is it advisable to disable some helper methods in the test environment for rails?

I have an application helper which determines the css classes (selected or unselected) and link addresses for the navbar at the top of my application helper. When I test my controllers, I get a whole bunch of errors regarding the navbar (variables return nil). Since the navbar has nothing to do with each individual controller, and it ap...

Finding all by Polymorphic Type in Rails?

Is there a way to find all Polymorphic models of a specific polymorphic type in Rails? So if I have Group, Event, and Project all with a declaration like: has_many :assignments, :as => :assignable Can I do something like: Assignable.all ...or BuiltInRailsPolymorphicHelper.all("assignable") That would be nice. Edit: ... such that...

Rails global content_for

Example: I have 2 partial _map.haml and _bigmap.haml. :: _map.haml - content_for :map do %script{:type => "text/javascript", :src => "http://maps.google.com/maps/api/js?sensor=true"} ... :: _bigmap.haml - content_for :bigmap do %script{:type => "text/javascript", :src => "http://maps.google.com/maps/api/js?sensor=true"} .....

Zend Framework helpers path problem

[2] fopen(/var/www/vhosts/tuthost/httpdocs/application/controllers/helpers/ViewRenderer.php) failed to open stream: No such file or directory in file: /var/www/vhosts/tuthost/httpdocs/library/Zend/Loader.php on line: 165 [2] fopen(/var/www/vhosts/tuthost/httpdocs/application/views/helpers/HeadTitle.php) failed to open stream:...

Zend Framework problem with autoloader.

it's all in index.php /* Define site root */ defined('DOCUMENT_ROOT') ? null : define('DOCUMENT_ROOT',realpath(dirname(__FILE__))); defined('SITE_ROOT') ? null : define('SITE_ROOT',realpath(dirname(DOCUMENT_ROOT.'../'))); // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', SITE_ROOT . ...

"undefined method" when calling helper method from controller in Rails

Does anyone know why I get undefined method `my_method' for #<MyController:0x1043a7410> when I call my_method("string") from within my ApplicationController subclass? My controller looks like class MyController < ApplicationController def show @value = my_method(params[:string]) end end and my helper module ApplicationHelp...

Zend framework helper intellisense

Not so much a programming problem, but more a productivity problem. We've got quite a few custom view and action helpers in our project. Working with around 7 programmers. Now when someone, creates a helper or if one would want to use a helper, it all goes through the brokers. This means we do not get intellisense for those helpers, w...

Cakephp 1.3 JsHelper for AjaxHelper

Hi: I'm start using cakephp and i made a demo app using AjaxHelper $ajax->link('title', 'url', array('update' => 'mydiv')) Now i want to migrate that to cakephp 1.3 and AjaxHelper is deprecated on cake 1.3 and will be removed, so i want to accomplish the same with JsHelper which is replacing the functionality of AjaxHelper and Javascr...