similar to: Determine which action, which controller is calling ?

Displaying 20 results from an estimated 10000 matches similar to: "Determine which action, which controller is calling ?"

2006 Mar 08
7
Function could determine the caller action ?
Is it possible to determine which action call the function ? In example, func_test in ApplicationController could determine which action from SiteController is calling her ? in class ApplicationController I have def func_test if ( calling from index ) return "1" end if ( calling from contact ) return "2" end end and in class SiteController def
2005 Mar 24
3
Caching computation in rails?
Caching computation in rails? Simple example: factorial modulus a large number input: integer x output: factorial( x ) % 12345678901234567 I want it so that if it computes factorial of N once, it will not have to compute for N again. code: class SiteController < ApplicationController caches_action :factorial, :inv def examine @inv = @params[''inv''] @outv =
2005 Aug 17
4
Stop an action ?
Hi. I am working on a generic authentification system for rails (more complete than the login generator). The way it works is you call a method inside your action, passing the domain as a parameter (domains are like a group of users with specific rights). For that purpose, I need to exit the action inside this method because it redirects to a login page if that person isn''t
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all actions...and their views? eg. class ApplicationController < ActionController::Base @current_user = User.find(session[:user_id]) end and everywhere I can call @current_user.id and I can get that object? Even down in the views? I could not get this to work... Thanks in advance, Jeff -------------- next part
2006 Jan 29
3
SHLG and lib dir
Slowly figuring out how to get my SaltedHashLoginGenerator stuff working. The wiki page says to put "before_filter :login_required" in the user (my "user" is "member") controller or in ApplicationController. However, wherever I put it I get NoMethodError. The rest of the SHLG stuff seems to be working... or at least I could get to the signup page, register, and
2006 Apr 14
1
Rendering an ApplicationController''s action
Hi ! I''ve pasted Rails Recipe #31: Authentication code, but I wish to use these methods in several controllers. Then I pasted them in ApplicationController, using before_filter method in all the other needed controllers. The problem is that Rails always tries to render a missing template inside the current controller ( app/views/controllers/admin/article/signin_form.rhtml ) while
2006 Feb 02
4
How switching global layout (application.rthml <or> custom.rhtml)
Dears, My railsapp run using ''/layout/application.rhtml'' and under some conditions ( Authenticated user, url parameter) I like to switch globally to another layout, let''s say custom.rhtml Like : class AppController < ApplicationController before_filter :context_layout def index end end # application.rb def context_layout if <context_condition>
2006 May 25
5
Setting a global before_filter action in application.rb
Can you set a global before_filter action in application.rb? So, for example, you could control authentication for all of the controllers in an app.? Obviously, you would need a way to reference actions by controller within this "global before-filter". Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2007 Nov 20
3
Plugin: can't call before_filter in ApplicationController
Hi all I want to outsource an extension for ApplicationController, that I had in application.rb so far, into a plugin. I have created this plugin, and in init.rb I load require File.dirname(__FILE__) + ''/lib/application_controller'' In lib/application_controller.rb I have the following code: class ApplicationController before_filter :prepare_user ... end This worked
2009 Apr 24
4
Undefined method "redirect_to" in before_filter
Code sample: class SomeController < ApplicationController before_filter do |c| add_crumb "Blah", "/blah" #breadcrumbs plugin redirect_to :controller => "foo", :action => "bar" unless c.send (:has_package?) end # Rest of the controller... private def has_package? # A bunch of logic work to check to make sure # somebody''s session contains
2006 Jan 30
5
a RJS problem/patch
Hi, add_rjs_to_action_view.rb of javascript_generator_templates doesn''t work with setting Content-Type in a controller. (e.g.) http://wiki.rubyonrails.org/rails/pages/HowtoSetDefaultEncoding class ApplicationController < ActionController::Base before_filter :set_charset def set_charset @headers["Content-Type"] = "text/html; charset=utf-8" end end I
2005 Dec 30
6
call a method once per page request
Hi, I''m wondering if there is a simple solution to call a method once per page request. I tried to place my call in a before_filter in ApplicationController but it''d called a second time if I use render_component from a view. Seems to me that a hook should be added in Dispatcher#prepare_application. Context: working on i18n, I''m trying to check lang either from uri,
2009 Aug 06
13
Redirect after login
Hi, I''m new to Ruby/RoR so please bare with me! I''m trying to adapt a ruby setup where someone logs in to a bonjour service via a web browser. I have the login screen which asks for host and password. There is only one user per host and i can log in fine. It''s suppose to redirect me to /list in my browser but doesn''t. Once i''ve entered the correct
2006 Apr 21
8
web services and dealing with before_filter
Hi all, I''ve got a Rails app with a ApplicationController that looks like this: class ApplicationController < ActionController::Base before_filter :authorize, :except => :login def authorize unless session[:user] flash[:notice] = "Please log in" session[:jumpto] = request.parameters redirect_to :controller =>
2012 Apr 21
13
issues with changing directory structure in rails3
class BranchesController < ApplicationController def branch @branch = Branch.new (params[:branch]) branch_back = @branch.*branch* end end in the model have one *branch.rb* class Branch def branch end end In the view have one branches folder, also have the branch.html.erb in that folder. <%= form_for(@branch) do |f| %> <%end%> *routes.rb* * * match
2006 Jan 30
2
Modules, controllers and inheritance
Hi! I was trying to cleanup my app and I runned into quite a problem. My controllers in submodule do not seem to inherit things from base class. I have following setup: app/controllers/ application.rb: class ApplicationController admin/ admin_controller.rb: class Admin::AdminController < ApplicationController include LoginEngine include UserEngine
2013 Feb 14
1
create object after before_filter :authenticate_user!
hi I use devise and cancan my model class PostsController < ApplicationController before_filter :authenticate_user!, only: [:create, :update, :destroy] ... end so an unauthentificate user can access new post form. Now when unauthentificate user submit new or edit forms, he is redirected to login form. But when he logs in, his post is not save in database. Is there anythings to do such
2007 Aug 27
2
Can FILTERS AND VERIFICATION functions take arguments?
Hi, I have some problems in using filter. My filter functions need to have arguments, but filter functions take only symbol that refer to function name. Consider the following code: class BlogController < ApplicationController before_filter :authorize For instance, authorize need arguments. So how can I pass arguments to filter function? Any helps always appreciate.
2006 Jan 11
7
before_filter: how to give :except more than 1 value?
Hi all I have the following class: class MemberController < ApplicationController before_filter :authorize, :except => :index def index ... end Now I want to give the before_filter more than one :except argument. I tried :except => {:index, :login}, but this didn''t work. How can i accomplish this? Thanks a lot and have a nice day, Josh -- Posted via
2006 Mar 04
6
Determine if a value is an instance of String , or Array , or...
each loop inside a mixed hash I need to determine if the value is an instance of String How ? hash.each do |k,v| if v ( instance of ) String hash[ k ] = v.capitalize enf end