search for: helper_methods

Displaying 20 results from an estimated 56 matches for "helper_methods".

Did you mean: helper_method
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)
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
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 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 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 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
2006 May 31
5
undefined method `redirect_to''
Hi all I have followed this tute: http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger to get rails running and all is fine except for getting: undefined method `redirect_to'' when I load my test page. I have the following in my xx.rhtml: <%= select :group, :user_id, find_all_groups, {}, {:onclick => select_group, :size => find_all_groups.size + 1}
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)
2011 Apr 05
4
Rails 3.0.5 gives SQLite3::SQLException for the same code that works on 3.0.3
Hello, I recently updated Rails to 3.0.5. The very same code that worked on 3.0.3 now gives error. The code is: def kategorialista Kategoria.where(:elfogadva => TRUE).order("nev").collect {|s| [s.nev, s.sefuri]} end It is in application_controller.rb with helper_method :kategorialista The error it gives on 3.0.5: SQLite3::SQLException: no such table: kategoria: SELECT
2007 Dec 05
4
render :update and controller private methods
Probably asked and answered, but... Why are controller private methods inaccessible inside the block passed to render :update ? This does not work: class MyController < ApplicationController def some_action render :update do |page| page.replace_html ''an_element'', some_private_method end end private def some_private_method return
2011 Jun 09
8
Fail to call
Hi, I''m trying create a user system for a future project but I have a problem when I want give to my users the "Welcome". This is my code: #application_controller class ApplicationController < ActionController::Base protect_from_forgery helper_method :current_user private def current_user_session return @current_user_session if defined?(@current_user_session)
2006 Jun 28
0
Getting name of currently rendering ERb template in view?
If I''m writing code in a template and I want to refer to the name of the template itself so that I can pass it to a helper method, is there a built-in variable (like controller_name or action_name) that I can use. Assume x.rhtml and in this template I have helper_method(). I want to pass "x.rhtml" into helper_method without hardcoding it. Do I have access to the _currently
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
2006 May 08
3
MVC newbie question
All, Is it possible for a view to call back to a controller method? If so, what is the syntax? === details I have a list view that I want to filter out inactive rows based on several table fields being zero, old, etc. It would seem I should create a "filtered" method in the controller (which I have done). Then invoke if from the view like: for row in @rows continue if row.filtered
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
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/.
2011 Mar 09
1
undefined method `flunk' for #<Spec::Example::ExampleGroup::Subclass_1:0x0000000516bd40>
I''m running into an issue using ONLY rspec version 1.3.3 (no rails / rspec-rails with this project) where i''m hitting the following error: My code looks like this: describe Win32Meterpreter before :all helper_method end def helper_method ## If a session came back, try to interact with it. if @session
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 Oct 28
1
Authlogic Page View Authentication Help
Hi: I am a newbie at ROR, and I am grasping my head around Authlogic. I am having hard time trying to figure out how can I do the following: in my application controller I have the following helpers: filter_parameter_logging :password, :password confirmattion helper_method :all private def current_user_session return @current_user_session if defined? (@current_user_session)