similar to: Where to put code - app controller, or app helper?

Displaying 20 results from an estimated 1400 matches similar to: "Where to put code - app controller, or app helper?"

2005 Dec 19
3
Trying to make an app helper
Any ideas with fixing this? Doesn''t work properly, although it doesn''t throw any runtime errors. # Methods added to this helper will be available to all templates in the application. module ApplicationHelper def options_for_months(selected_month)
2005 Dec 20
2
Designing a data-entry screen
Here''s what i''m trying to do: Have 3 dropdowns up the top of a page, being: year, month, department, and group. Also a button underneath that called refresh. When you click refresh, it finds the 1 row of data from the database for that year/month/dept/group and populates the fields into a set of textboxes below. Then you can edit what is in those textboxes, and click a
2005 Dec 19
1
Application.rb / Application_Helper.rb / DRY help
Hi all, I have defined the following method in both application.rb and application_helper.rb: def still_logged_in? !session[:user_id].nil? end This method is called in a before_filter in my application.rb, as well as in my layout/application.rhtml and view/user/login.rhtml (for showing a login / logout button, etc.) I had to put it both places, otherwise I would get an
2005 Dec 19
15
OpenSSL ''no ciphers'' error on OS X when using Net::HTTP
OpenSSL::SSL::SSLError: SSL_CTX_new:: library has no ciphers This error is thrown whenever I use anything that uses Net::HTTP. OS X Tiger, ruby 1.8.2 (2004-12-25) [powerpc-darwin8.2.1] What could it mean? Joshua Sierles
2008 Nov 10
3
to_xml and helper methods
Hi, I have an array with objects and I want to generate an XML like: <objects> <object> <category_id>1</category_id> <helper-method>result 1</helper-method> </object> <object> <category_id>2</category_id> <helper-method>result 2</helper-method> </object> </objects> The helper
2006 Jan 17
9
Formatting a float with a set number of decimals
Another newbie question: How do i convert a float to a string, rounded to a certain number of decimals? Thanks -- Posted via http://www.ruby-forum.com/.
2006 Jul 26
7
Delete_all causes a deadlock on MSSQL database ???
Hi all, When i use the ''delete_all'' function to remove a few rows from my database, it causes a deadlock on the sql server. The delete seems to be successful, it then redirects to the ''view'' page, and the record does appear to be deleted as far as the ''view'' rails page shows. BUT if i go into sql query analyser, i can''t do a
2005 Dec 19
10
missing shortcut
I''m trying to start RubyGems on my hd. Windows searches for and can''t find a file named gemhelp.cmd Can I download that files somewhere? -- Posted via http://www.ruby-forum.com/.
2006 May 02
1
Sharing function between helper and controller
Hi, I have a utility function repeated in both my helper and my controller. Not DRY. I have this repetition because other functions in the helper and in the controller both use the utility function. Where do I put this function so that both the helper and controller can access the function? Mayber there is a different solution? Thanks, Peter
2005 Oct 12
1
Global helper method?
I want a method to be accessible from everywhere in my app (it''s a Gaussian RNG) - I''ve already put them as protected methods in application.rb but that would only allow them to be accessed from controllers. I have a method in a model that needs access to this too, and I''d prefer not performing the calculations outside the model. Copying the method definition into the
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
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)
2006 Mar 27
3
Define methods for controllers, helper AND models?
Hi all I know that I can define methods in e.g. the application controller and make them available to the helpers using helper_method(), but how can I make them available in the models? I have for example the following method, that I want to be able to call from any model I wish... def ApplicationController helper_method :member def member session[:member] end end Thanks for any
2006 Feb 08
9
InPlaceEditor - IMG for OK / Cancel?
Hi all, Is it possible to use images instead of plain text for the "OK" and "Cancel" controls? Thanks, Best Regards, EJC _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
2006 Feb 20
2
Problem with flash[:notice] appearing twice
In my save function in my (ajax!!!) controller, i''ve got a bit like this: if ... flash[:notice] = ''NOT SAVED: This month is locked'' render :partial => ''edit'' else save it... redirect to ''show'' action.... ... If i try to save an entry for a locked month, it correctly brings me back to my edit action with the
2006 Jan 17
2
How to run direct sql
How can i run and get the value from the following sql: select avg(my_field) from my_table where which_year=''0506'' and which_week <= 21 and my_foreign_key_id=10 cheers -- Posted via http://www.ruby-forum.com/.
2008 Jun 13
3
before_filter order of execution
Hi I''m trying to use before_filter to allow access to a site. Only logged in users can view any object in the controller, but only users with a access_level higher than 2 can view specific objects. My code is: ----------------------------------------------------------- IN USER_CONTROLLER before_filter :login_required before_filter :access_granted, :only => [:destroy, :new , :edit]
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
2006 Jan 24
4
How to filter an activerecord find_all...
I have a nice hierarchical table structure like this: divisions has_many groups groups belongs_to division has_many subgroups subgroups belongs_to group has_many units units belongs_to subgroup I have a report which is based on units, but i want to be able to filter the units by which subgroup, or which group, or which division. I also want to sort them by division.name,then group.name,
2006 Jun 24
7
Newbie Q: "user" variable in every view?
Newbie to RoR -- as a long time Java Struts/etc. guy it is an awesome tool! I have implemented some basic login/session stuff with the help of a great tutorial, props to the author ( http://www.aidanf.net/rails_user_authentication_tutorial). I have a trivial instance method in ApplicationController, which just grabs the User object from the session. def current_user session[:user] end