search for: myhelp

Displaying 13 results from an estimated 13 matches for "myhelp".

Did you mean: mhelp
2007 Jul 14
2
Using Helpers inside a Controller
...s forms that require helpers because I can''t call the helper inside of the controller. I searched the web for a workaround and came across code to be defined insider your controller: def help Helper.instance end class Helper include Singleton include ActionView::Helpers::MyHelper end But no dice. I get an uninitialized constant error for ActionView::Helpers::MyHelper. If I instead include just MyHelper, then rails complains that the helpers that are used inside MyHelper are now undefined. I really don''t want to construct the forms inside my controller, but...
2013 Feb 03
4
Create a helper for models and views?
Hi! If I have a method that is useful in both models and in views, where would be the appropriate place to put it? The method in question just takes two dates as strings, tries to parse them and returns all dates in the range between them. It also takes care of the issues when the dates are badly formatted etc etc.. This method is being used in several models (so a simple class method in
2010 Mar 13
1
Testing file upload (Sinatra, RSpec, Rack-Test)
...o add a file upload functionality. How can I write a spec? Here''s my try. # directory structure app: - controller.rb - controller.spec.rb - files: [] - fixtures: [test_file.png] # controller.spec.rb require ''rack/test'' require ''controller'' module MyHelpers def app Sinatra::Application end end Spec::Runner.configure do |conf| conf.include Rack::Test::Methods conf.include MyHelpers end describe ''Application'' do it ''should accept uploaded files and save them into the `files` directory'' post ''/...
2006 Apr 19
8
Module and Model
I am getting the following error /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1129:in `method_missing'': undefined method `directory?'' for Msg::File:Class (NoMethodError) I have a model called Msg::File in models/msg/file.rb, and I have a file in lib/msg/helper.rb which references to both Msg::File and File.directory? How do I help activerecord
2007 May 21
4
Just upgraded to 1.0.0, should render_text isn''t working for me
I finally got around to upgrading from 0.8.2 (!!). I had a spec which looked like specify "should render abc123" do controller.should_render :text => "abc123" get :key end With 1.0.0, the new spec is it "should render abc123" do get :key response.should render_text("abc123") end However it doesn''t work, giving me the error: undefined
2007 Jan 04
8
Common setup code and naming specifications
Hello! I have a lot of contexts for testing Rails controllers, that must do something like ''session[:logged_in] = true'' in their setup. How can this be refactored? In unit tests I would simply create a LoggedInControllerTest base class, that all my functional tests would derive from. And another small question: In my controller specifications I often have to decide whether to
2006 Jun 16
3
Not able to recognize helper class method in controller!
Hi, Not able to recognize helper class method in controller! When I try to call some method "get_formatted()" in my controller, it says local method not recognized. Please help me out. Thanks, josua -- Posted via http://www.ruby-forum.com/.
2006 Feb 25
1
extending a class
I''m trying to add this to my project: class String def escape_quotes self.gsub(/["'']/) { |m| "\\#{m}" } end end I tried putting it in application_helper.rb, but it''s not getting found. Where does it need to go? Thanks, Chris -- Posted via http://www.ruby-forum.com/.
2006 Mar 04
13
Using helpers from controllers ?
There is a solution to use helpers from controllers ? I have an error : |undefined method `content_tag''| class ApplicationController < ActionController::Base def test return content_tag("a","test") end end
2006 Dec 24
6
What do you think of this controller spec?
Here''s a controller spec I wrote, it''s for a very simple RESTful controller (well, aren''t all RESTful controllers simple? :) I''ve created a couple spec helper methods to refactor some of the common code...for example, require_login_and_correct_user creates two specifications: one for when the user isn''t logged in, and one when the user is logged in but
2006 Jan 15
4
model helper location
Hi, I''m looking at the rails cookbook for uploading files[1]. At the bottom of the page it says that the sanitize_filename functioin would probably go in a helper or a library. I wonder where these files would be or what they would be called. Pehaps there are some conventions I need to know about? Thanks, Peter [1] http://manuals.rubyonrails.com/read/chapter/78
2006 Nov 16
2
Stubbing helpers
Hi, Is it possible to stub out a helper for development? I''ve got a (view) helper that renders a partial and runs all kind of javascript. But for dev purposes I''d like it to return some hardcoded html. I''m not having any success stubbing the helper out. Something like... test/mocks/development/helper_stub.rb require ''application_helper'' class
2011 Sep 13
3
Accessing Rails helper method with_output_buffer
...ted in the form_for helper docs in the Rails source: ========== <%= form_for @object, :builder => MyFormBuilder do |my_form| %> <%= my_form.my_dummy_div_wrapper do %> <%= ... %> <%= end %> <% end %> ========== Here''s the helper: ========== module MyHelper class MyFormBuilder < ActionView::Helpers::FormBuilder def my_dummy_div_wrapper(&block) output = "<div>".html_safe # here I should use with_output_buffer to correctly get the block''s output output.safe_concat(with_output_buffer &block)...