similar to: Automatic helpers for controller modules?

Displaying 20 results from an estimated 80000 matches similar to: "Automatic helpers for controller modules?"

2007 Jul 14
2
Using Helpers inside a Controller
I want to use helpers inside a controller method for an AJAX application. After the page is loaded and displayed, there will be an asynchronous javascript request to load additional resources such as html forms and other data. The controller which handles the request will collect the resources and send them back in json format. def get_resources data=Hash.new data[:form1]=form_helper1()
2006 Jan 20
1
stack level too deep from has_many / belongs_to relationship
I have the following 3 models (2 models joined by an intermediate): 1. class Exercise < ActiveRecord::Base 2. has_many :routines, :class_name=>''RoutineExercise'' 3. end 1. class Routine < ActiveRecord::Base 2. has_many :exercises, 3. :class_name=>''RoutineExercise'', 4. :order=>''position'' 5. end 1. class
2007 Dec 11
3
can''t access helper methods for model testing
I would like to have some valid mock models readily available in the helper module, but when I try to access the helper I get the error saying that the method is not found. ======= describe MembersHelper do # Helper methods can be called directly in the examples (it blocks) def valid_member_mock member = mock_model(Member) member.stub!(:first_name).and_return("Joe")
2010 Sep 24
0
Rails 3, using helpers in controller
Hi everyone, is there any way how to use Helpers in Controllers in Rails 3? I was trying to google about it, but no luck. In old Rails times (2.x) we were using something like this. my_active_record_object.variable = "This is the message body:<br /><br /> #{@template.simple_format(params["message"])}" point is that when we wanted to attach text from Text Area to
2007 Jul 24
4
spec''ing helpers that use controller
Hi all, I''m in the process of creating rspecs for my helpers. One of the helpers in app/helpers/application_helper.rb looks like this: def page_name @page_name || "Define @page_name in #{controller.controller_name}::#{controller.action_name}" end The rspec is simply: it "should something" do page_name end
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
2010 Nov 17
3
How to use request helpers outside of controller specs?
I asked this questions on some other places before, but have found no solution yet. I''d like to include the request helper (from ActionDispatch::Integration::RequestHelpers, like post and xhr methods) also in some specs outside of my controller specs. The problem is that these request helpers are only included in spec/ controller and when a controller is described. What do I have to
2005 Apr 06
3
NameError in <controller not set>#<action not set>
I can''t figure out why I''m getting the following error. There''s nothing wrong in my communities_controller file. And the helper for communties exists. Any ideas? Thanks, Joe NameError in <controller not set>#<action not set> uninitialized constant CommunitiesHelper app/controllers/communities_controller.rb:1 script/server:48 Show framework trace
2006 May 29
2
Adding model fields
I added a field "url" to a table, modified the view to show the new field. Now I''m getting an error in the code that processes the form in the view: copy_from_item = Item.find(params[:id]) @item = Item.new(copy_from_item.attributes) The second line here gives this error: undefined method `url='' for #<Item:0x246e3f0> RAILS_ROOT:
2006 Apr 23
5
Controllers in folders and helper scope in Rails >1.0
Hi, Here''s my problem. I tried to google it, read the release-docs and haven''t found anything similar. My application uses folders to store controllers, as described in the Rails book. I need to have same-named controllers for admin and for users, so it looks like this: /app/controllers/admin/project_controller.rb /app/controllers/admin/...
2011 Jan 03
2
Adding style to model (paperclip)
hello, I have a model (item) with one attachment (photo) and one style (small): class Producto < ActiveRecord::Base has_attached_file :photo, :styles => { :small => "50x50"}, end I would like to add a new style (:large), so I modify item.rb: class Producto < ActiveRecord::Base has_attached_file :photo, :styles => {{ :small => "50x50"},{ :large =>
2007 Nov 01
0
Using view helpers from a controller
Hi, I want to access a view helper from a controller. (Of course, you all want to know why??? -- See below.) To be specific, I want to access methods such as ActionView::Helpers::FormTagHelper -- form_tag and text_field_tag from either a controller or from a new class (in models? or lib?). If I create the new class then that class''s methods need to also be able to access the
2006 Apr 24
7
Controller can''t find helper?????!!!!!????
I have a controller named xyzController under app/controllers I have a helper class named xyzHelper under app/helpers. Shouldn''t I be able to call methods from xyzHelper inside of xyzController without any problems? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 May 21
6
Is there a way to call helper methods in a controller?
Hi, Is there a way to call helper methods in a controller? I want to do something like this in my controller Class MyController < Action.... def my_method string = link_to "some_url", :controller => "home", :action => "command" end end link_to is an ActionView helper method and it seems that I couldn''t access the method in the controller
2006 Jan 23
2
UserEngine -- Permission.synchronize_with_controllers -- trouble with my own controller modules
I suspect there''s an easier version of this question that I could ask, but I''m not sure where I''m going wrong. I have LoginEngine and UserEngine setup and seemingly running fine. However, not all of my controllers are being found when I run "rake sync_permissions". Specifically, it''s the controllers that are not in the base controllers folder, but
2006 Aug 16
4
Accessing Constants Declared in Helper Modules
Hello all, I''m having great trouble accessing a constant declared in a helper for one of my view templates. I am trying to create a grouped selection list based on a predefined set of values. Rather than declare this set of values in the view, I wanted to put it in the helper that automatically gets included for the view. Unfortunately, it doesn''t seem to work. All methods
2006 Oct 21
0
@helpers no longer required?
After updating to the latest version of Markaby, I''ve noticed that @helpers doesn''t seem to be necessary when accessing params, flash, etc. and named routes (*_url) in Rails. Is and will @helpers no longer be necessary? (And if so, let me be the first to say YAY!) Thanks, Joe __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the
2007 Nov 03
1
Specs for Helpers that call render
The helper spec I am writing tests a helper method that calls render. ## module HelperHelper def render_partial render :partial => ''partial'' end end ## The helper spec. ## describe HelperHelper do it "should render partial" do render_partial.should_not == nil end end ## The output generated ## $ spec spec/helpers/home_helper_spec.rb .F 1)
2006 Aug 04
0
How do you use form helpers in your controllers or classes?
I need to use the number_with_precision Form helper in my controllers and classes. How do i do this? Thanks in advance Chris -- Posted via http://www.ruby-forum.com/.
2006 Apr 04
2
HABTM
Hi. Im new to Ruby and new to Ruby on Rails and have problems realizing a =20= simple many_to_many relationship: My tables: items <-> items_users <-> users ------------------------------------------------------------------------=20= -------------------------------------- id user_id = id name item_id name ... = password = ...... My Code: class