Displaying 20 results from an estimated 4000 matches similar to: "Controller-wide instance variable"
2007 Dec 03
2
before_filter application => exclude some other controllers
Hello again,
It''s possible to use before_filter in the application_controller, and
exclude for some methods from other controllers ?
i have a before_filter in application_controller that checks if the user
is logged, if the time hasn''t expired, ... and I want to exclude some
methods of this check, like the login. This ''login'' belongs to other
controller.
I
2006 Jul 25
5
webrick server slow or does not connect
hi,
In login_controller.rb when I do the fallowing code it works fine
before_filter :authorize, :except => :login
but I want to do the fallowing when creating the user so the
authorization is not checked
before_filter :authorize, :except => :login, :except => :create_user
but when I do this webrick server appear to be slow or not connected and
take lot of time to load?
Could someone
2006 Jan 30
5
Functional tests and dealing with login before_filter
Hi all,
I''m curious as to how you do functional testing on the controllers if, within
the ApplicationController, I have a before_filter :authorize, :except =>
:login, where the private authorize method checks for session[:user].
I can''t do "post :login", because that method is in a different controller.
I tried setting session[:user] directly in the setup
2012 May 01
1
uninitialized constant LoginController in Ruby
This is my environment.rb
# Load the rails application
require File.expand_path(''../application'', __FILE__)
# Initialize the rails application
Qstack::Application.initialize!
require ''koala''
This is my application_controller.rb
class ApplicationController < ActionController::Base
# protect_from_forgery
before_filter :parse_facebook_cookies
def
2005 Nov 03
9
[Idea] session-wide persistent variables
I was thinking about having instance variable stored and fetched from
session container automatically before calling an action and after the
action is finished. Using methodology of accessors it would look like:
class MyController < ActionController::Base
persistent_attr :person
def alfa
person = ''John Smith''
# render as usual view alfa.rhtml with anchor
2006 Apr 05
6
Howto add application-wide variables?
I suspect this is something I should know already but I can''t seem to
get it right, how can I create application wide variables and have them
accessible to all my controllers?
I tried creating a plugin and having my controller require a specific
method from that plugin to access its variables but that didn''t work, so
I am left scratching my head.
eg from plugin
2010 Jul 02
6
making something available application wide
I''d like to display a banner on every page. Ultimately I''ll be tweaking
which banner is displayed via different controllers but initially I''d
just like to set a single banner application wide and display it in my
"_header", a partial I include in all layouts.
I''ve got a BannerAdvert model, simple. If I''m in my welcome controller
index action
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 Oct 19
1
Question about variable assignments/scoping after render call
I''ve got a question about how variables are made available to templates. We
have a test that looks something like this:
def test_variable_assigned
xhr :get, :do_stuff, :id => 1
assert_not_nil assigns(:thing)
end
And our app code looks like this:
class SuperClass < ActionController
def do_stuff
@parent_model = ParentModel.find(params[:id])
render :template
2006 Apr 06
9
How to get Form values in RubyOnRails
Hi
I want the FORM values on my controller.i.e. I want the values of login_loginname(Form variable) and login_password(Form variable) on login_controller.rb
How can i do that?
Table Name is: logins
Model:: Login.rb
Controller:: login_controller.rb
Below is my test form
loginname
password
Hoping for reply
Regards
Parikshit
2005 Jun 01
3
Mixing Controllers
I have a login section that is part of my view from my sign_up
controller. Validating my user happens through a login_controller.
Now if validation is good it is ok because I have a redirect in my
login_controller. But if the login is not successful I have to go
back to my view from my sign_up controller. Using redirect makes no
sense because my @user_login object is lost and so are
2006 Apr 07
6
Multiple view types for a single action?
Is it possible to have more than one kind of view for a specific action,
for example an .rhtml and a .rjs file to handle the view for the same
action?
I suspect not, but this makes me wonder if there a way to call the .rjs
file from within the .rhtml so the statements within it get executed?
Thanks,
Andy
2006 Jul 29
2
Instance Variables within Controller during AJAX request
Hey all,
I''m trying to do something sorta simple...
There are three button ids: ''view'', ''build'', ''search''
My controller looks like this:
class RandomController < ApplicationController
before_filter :login_required, :except => [:index, :initialize]
def initialize
@mode = ''view''
end
def index
2006 Apr 10
3
form_remote_tag : additional onsubmit funct. possible ?
Is there a way to add onsubmit functionality to a form_remote_tag with
an additional javascript directive?
eg I''d like for an inline javascript to make the form''s div container
hidden as soon as the button is pressed to avoid having it possibly get
pressed again ( sometimes the rails response is slow enough for a user
to think they need to re-press it ).
example:
<div
2006 Jun 13
7
ActiveRecord attribute= overload
I want to overload the = operator for one of the attributes in a model
to run a filter on the input. However I can''t do this:
def attribute=(data)
self.attribute = filter(data)
end
because that creates an infinite recursive loop.
How do I get around this?
--
Posted via http://www.ruby-forum.com/.
2006 Aug 15
3
instance variables in layouts
There''s probably a simple answer to this simple problem, but I am trying
to figure out how to reference an instance variable within a layout. In
the controller, one method corresponds to a view of the same name. Those
instance variables in the method can be used in the corresponding view.
However, I want my instance variable to be accessible throughout all my
views, not just one,
2006 Aug 01
2
Partial Naming Madness
Hi, I am having the following issue with a partial. During initial page
load, I am doing a "render_partial_collect ''foo'', @foos", and all goes
well. Each foo partial makes use of a variable inside called ''foo'' (and
can get foo.id etc).
After all the partials are loaded, I need to :update a div corresponding
to one of the partials (ie re-load the
2006 Apr 13
8
Controller paths
Hi there.
Suppose I create some controllers like
ruby script/generate controller Admin::product add remove
ruby script/generate controller Admin::user add remove
ruby script/generate controller Login login logout
the directory structure will be
app/controllers/admin/product_controller.rb
app/controllers/admin/user_controller.rb
app/controllers/login_controller.rb
Now suppose I need some links
2006 Jan 12
17
Application.rb params
I need to check if a parameter is set so that I can build some information
for my application, but No matter how I format my if statement in the file "
Application.rb" it return the following error.
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
Here is the line
if params[:day]
So we
2006 Aug 10
4
1.1.5 Upgrade and config.load_path not working
Hey,
I am trying to upgrade to 1.1.5 and rails no longer finds my controllers the
live outside app/controllers. I was on 1.1.2 previously and here is my
setup
In environment.rb
config.load_paths += [File.join(File.expand_path(RAILS_ROOT),
"rails_shared/controllers") ]
config.load_paths += [File.join(File.expand_path(RAILS_ROOT),
"rails_shared/helpers") ]