How do I test helpers in Rails?
I'm trying to build some unit tests for testing my Rails helpers, but I can never remember how to access them. Annoying. Suggestions? ...
I'm trying to build some unit tests for testing my Rails helpers, but I can never remember how to access them. Annoying. Suggestions? ...
I'm testing my rails helper methods like this: require File.dirname(__FILE__) + '/../../test_helper' require 'action_view/test_case' require 'action_view/helpers' class ListingsHelperTest < ActionView::TestCase def setup @controller = ListingsController.new @request = ActionController::TestRequest.new @response = Action...
I am searching for a way to make an application helper that allows you to define methods that you can call in all the controllers views. In Rails you get that for free but how can I accomplish this in ASP.NET MVC with c#? ...
For example, why are the date helpers written like this: time_ago_in_words(@from_time) Instead of like this: @from_time.time_ago_in_words Is this a clear design error / inconsistency? Or is there some reason for this? ...
I'd like to, for all helpers, across my entire Rails application, replace this syntax: time_ago_in_words(@from_time) with this: @from_time.time_ago_in_words Ideally this change would also make the helpers available anywhere in my application (the same way, say, 5.times is). Does anyone know of a plugin that does this? Would it be ...
hello, Im trying to create a helper method for my admin links. in quite a few views i have the code <% if current_user %> <%= link_to "Edit", edit_model_path(model) %> <%= link_to "New", new_model_path %> <%= link_to "Delete", model, :confirm => "Your a Noob", :method => :delete %> <% end %> that only display these when logged in. ...
In MonoRail controllers can be adorned with the Helper attribute to make helpers available in views. Is there another way to register helpers, perhaps via configuration file or dependency injection, with controllers? I'm keen on avoiding creating a base controller just for the purposes of providing helpers and adding yet another controll...
Why can I access helper methods for one controller in the views for a different controller? Is there a way to disable this without hacking/patching Rails? ...
Hi, Strange thing – I have Authentication module in lib/ like this: module Authentication protected def current_user User.find(1) end end and in ApplicationController I'm including this module and all helpers, but method current_user is available in controllers, but not from views :( How can I make this work? ...
Hi, I'm going to write a ton of helpers for my app. For many of them I'd like not to extend HtmlHelper, but to create another helper class instead, for two reasons: 1) to be able to write, say, Link.Home and Icon.Edit instead of Html.HomeLink and Html.IconEdit; 2) to be able to easily tell standard helpers from custom ones and where t...
I am trying to add some instance variables in helpers like the following: module ApplicationHelper def title=(title) @title = title end def title @title end end and when I assign title in views/pages/index.html.erb like the following: <% title = 'Listing Pages' %> and try to show it in the views/layouts/application.html.e...
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from BushyMark. I think I made all the suggested changes correctly, but I still can't get the post_type_id to save to the database when a user submits a message. My app has a profile page. On the profile page, the owner of the page can type an update and...
ExtJS provides some great helper functions like: Ext.extend() Ext.apply() Ext.namespace() Are there any equivalents in jQuery? I know I could port all three to jQuery since I like them so much, but maybe I'm missing something that's already there. I would like to avoid mingling with prototypes myself if possible. Endresult Ext.app...
Is there any way with the current delphi to implement. a) String (as a class) with operator overloads (ie. +, =) b) Class Helper's so one could add custom string methods I gather the string is a native type so class helpers will not work without setting up a class etc. ...
Hi there, All I'm trying to do is spec how a one line helper method for a view should behave, but I'm not sure what kind of mock object, (if any) I should be creating if I'm working in Rails. Here's the code for events_helper.rb: module EventsHelper def filter_check_button_path params[:filter].blank? ? '/images/buttons/bt_searc...
I have an html button setup and functioning with a set range of required properties that I'd like to convert to a text-based link instead. Additionally, so I can familiarize myself with working html helpers and intellesense I'd like to see how to shoehorn these properties into an ActionLink: <input type="button" id="RemoveRegistration_S...
Using CakePHP: I have a many-to-one relationship, let's pretend it's many Leafs to Trees. Of course, I baked a form to add a Leaf to a Tree, and you can specify which Tree it is with a drop-down box ( tag) created by the form helper. The only thing is, the SELECT box always defaults to Tree #1, but I would like it to default to the Tr...
Is there a way to do this in Rails: I have an activerecord query @posts = Post.find_by_id(10) Anytime the query is called, SQL is generated and executed at the DB that looks like this SELECT * FROM 'posts' WHERE id = 10 This happens every time the AR query is executed. Similarly with a helper method like this <%= f.textarea :name...
To include a Rails helper, helper :helper_name and to include all helpers, helper :all is specified in the application_controller. Now, how to include say N-1 of the available helpers? In other words, how to exclude a very few helpers? ...
Hello All, I am looking for a sample LOB/project that fully use MVVM Helpers by Julmar Technologies. Does any one have any links to share?. Thank you - Rey ...