Displaying 20 results from an estimated 4000 matches similar to: "Application.rb / Application_Helper.rb / DRY help"
2005 Jul 22
3
testing application_helper.rb
I am trying to run some functional (or are they unit?) tests on my
application_helper.rb. So far, I''ve not had any success in being able
to call the methods defined in application_helper.rb.
Here is my app/test/functional/helpers.rb
require File.dirname(__FILE__) + ''/../test_helper''
require File.dirname(__FILE__) +
2006 Nov 27
2
ActionMailer & application_helper.rb
Hi,
I''m trying to send some emails with the same formatting as my pages & I
can''t seem to access my display routines in application_helper.rb. I''m
trying a hack to bypass this.
At the top of my ActionMailer notifier script I''ve included
application_helper.rb - my understanding is that this should arrive as a
module and should be able to be used
2006 Jun 26
5
using application_helper.rb
I have a simple Yes/No selection list that I am using in a number of
places. Thinking that I could DRY things out a bit, I added it to
application_helper.rb ...
YES_NO = [
[ "Yes", true ],
[ "No", false ]
].freeze
So I figured I would use it there instead of in each model.rb where
needed.
anyway, in webrick screen, I am continually seeing this...
2006 Mar 16
1
application_helper.rb vs application.rb
I find that I want to put the same methods into both of these files.
Whats the best way to get away with a single implemenation?
Gareth
--
Posted via http://www.ruby-forum.com/.
2010 Nov 29
0
[TDD] [Rails] - Rspec test for application_helper.rb fails when trying to access application_controller method.
In a method named logo in my application helper, I reference an application controller method (current_account) that has been marked as a helper method with the following syntax:
helper_method :current_account
When I test out the setup in the browser (without rspec), rails is happy with this setup.
However, when I run the spec, the spec won''t pass and gives me the following error:
2005 Mar 10
8
Login controller additions
I have added roles and roles_users table and updated the model so that
my users can have multiple roles.
("Admin" role does always have id = 1).
I have added these methods to my application controller.
<code>
helper_method :is_admin?
helper_method :is_user?
def is_admin?
if @session[''user'']
@session[''user''].roles.find(1)
2005 Aug 16
1
Best way to access constants in application_helper.rb from views?
Hi,
I''m using the application_helper.rb file to create some useful functions
for generating links by name.
I understand that functions defined in this file are available to all
views, but what about constants defined in that module? Is there a
best practice approach for doing this other than accessing each constant
via ApplicationHelper::FOO?
Stu
2005 Dec 19
3
Where to put code - app controller, or app helper?
I have a function i want to be used in both views and controllers:
def year_to_fiscal_year(year)
# converts, say, an integer 2003 into ''0304''
year.to_s[2,2] << (year+1).to_s[2,2]
end
Where should i put it ?
--
Posted via http://www.ruby-forum.com/.
2006 Mar 04
2
application_helper can "include" another helper ?
My "application_helper.rb" become to large.
I have basic functions that I use for all projects.
Is it possible to define thoses functions inside an external
"basic_helper.rb" and include it in "application_helper.rb" ?
2009 Jun 05
6
rails 2.3.2
Hi all,
I am using rails v.2.3.2 and if I put following line to my
ApplicationController:
include LoginSystem
and I moved my login_system.rb to lib folder:
module LoginSystem
protected
def is_logged_in?
@logged_in_user = User.find(session[:user]) if session[:user]
end
def logged_in_user
return @logged_in_user if is_logged_in?
end
def logged_in_user=(user)
if
2006 Jun 27
5
Can''t call public application.rb method from ERb template
All,
I have a left navigation partial that I want to dynamically generate CSS
classes for based on the current controller action.
In my ERb template, I have
<DIV class="<%= get_menu_display_style(''login_form'') %>">
In application.rb, I have the method get_menu_display_style defined as:
public
def get_menu_display_style(action_requested)
2006 Jun 07
0
Problem with file_column plugin path and application_helper.rb
Hello,
I upgraded my Rails app from 1.0 to 1.1.2. Basically everything worked
on my development box. When I uploaded the changes (including the
frozen 1.1.2 gems) to my webhost most things worked. However I had a
problem with my application_helper.rb file. It wasn''t able to find the
url_for_image_column method from the file_column plugin. Here''s the
relevant code in
2006 Feb 26
0
ActionMailer view templates don''t pick up application_helper.rb?
It seems that helper methods defined in application_helper.rb aren''t
available in ActionMailer views.
Is that intentional?
--
- Adam
** Expert Technical Project and Business Management
**** System Performance Analysis and Architecture
****** [ http://www.everylastounce.com ]
[ http://www.aquick.org/blog ] ............ Blog
[ http://www.adamfields.com/resume.html ].. Experience
[
2005 Dec 28
2
form reset after successful form submission
hi,
what''s the way to reset the form generated by the form_remote_tag
after the successful submission of the form?
thanks
2008 Jan 21
3
A method accessible from all controllers and views ? How ?
Hi,
I''ve got this method :
def is_admin?
@current_user && @current_user.admin == 1
end
I want to be able to call this method from all my controllers and all my
views.
If I put this method in application_controller I can call it from all my
controllers but none of my views.
If I put this method in application_helper I can call it from all my
views but none of my controllers.
2005 Dec 15
10
.rpdf ?
I haven''t delved into the wonderful world of PDF::Writer yet, nor have I
run across a need.. but I just had an idea I wanted to throw out there
how hard would it be to create a .rpdf template plugin for rails?
could be neat ;]
2005 Dec 25
2
scriptaculous-js-1.5.0
I''m not a JavaScript guy, so please help me out.
It''s my understanding that Rails 1.0 includes scriptaculous-js-1.5.0
But it seems to contain portions of, but not the complete library.
Rails 1.0 includes 4 .js files, scriptaculous-js-1.5.0 includes 8.
What am I missing?
> tmornini$ rails --version
> Rails 1.0.0
>
> tmornini$ rails test | grep
2007 May 28
2
helper with block compile error
HI,
i''m trying to write a helper that replaces link_to_remote that
accepts a block but it gets a compile error in the template:
I don''t know what I''m doing wrong... TIA
# application_helper.rb
def link_block_to_remote( options = {}, html_options = {}, &block)
concat(link_to_remote(capture(&block), options, html_options),
block.binding)
end
# in
2006 Jun 27
6
embedding ruby code in a [flash :notice]
The ruby code in this isn''t evaluated...
flash[:notice] = "Your last recorded entry was <%= @in_out.time_in %>
<br />You are currently marked as ''In'', you probably want to check
''Out''"
Is there a way?
Craig
2005 Mar 06
3
Accessing login name from login_generator
I''m new to Rails and am modifying the ToDo tutorial app into something
else. I have successfully installed authentication via login_generator
and now I working toward restricting access to certain database records
based on the login name. I realize that eventually, I''ll want to use
the "id" field, but for now, I just want to use the user name itself.
I have