Displaying 20 results from an estimated 1309 matches for "applicationcontrol".
2007 Aug 14
2
Spec''ing ApplicationController
Folks,
I''d like to spec the behaviors that I''m adding to ApplicationController.
Specifically, I''m adding:
def authenticated?
session[:username] != nil
end
I described ApplicationController, but couldn''t figure out how to call the
authenticated method. I''m probably going about this quite wrongly and would
appreciate any hints?
Thanks,
Scott...
2006 Feb 03
4
(BUG in svn/trunk?) - superclass mismatch for any subclass of ApplicationController
I track svn/trunk of Rails using svn:externals
Some change to Rails committed in the last 1-2 days broke my subclass
of ApplicationController
The example, below, works with Rails 1.0, but in today''s svn, it dies
with the following error:
"superclass mismatch for class FooController"
class ApplicationController < ActionController::Base
end
class FooController < ApplicationController
end
The reason I'&...
2007 Aug 15
4
nuby: how spec redirect_to at ApplicationController
Good morning rspec people!
Still rspec nuby: I must do something wrong obviously.
How can I spec about redirect_to at ApplicationController
describe ApplicationController do
it "method login_required should redirect to home path without login" do
pending "I tried to use controller.login_required.should be_redirected
and got NoMethodError with nil object didn''t expect error."
end
end...
2006 May 18
3
access to an ApplicationController property from a view
Hi there,
How is it possible to get access to an ApplicationController property
from a view?
Consider this (simplified) situation:
class ApplicationController < ActionController::Base
def folder_id
@folder_id = params[:id]
return @folder_id
end
end
class FolderController < ApplicationController
def show
@folder = Folder.find_by_id(...
2008 Feb 08
0
Challenge! How can I write a test to test the methods in ApplicationController?
Hi all,
I''ve been Googling this one for a while now, and haven''t found a
satisfactory answer. It has been posted here before by someone else,
but it seems to have got forgotten, so here goes - perhaps someone can
think up a way around the problem?
In ApplicationController, I have the following method:
class ApplicationController < ActionController::Base
<snip>
helper_method :admin?
# Discover whether the currently logged user is an admin user
def admin?
User.find_by_id(session[:user_id]).admin? unless
session[:user_id].nil?
end
<snip&g...
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
So I can of course call this from within any subclass controller. All I am
now trying to do is implement it such that I have access to this user
automatically in every view. What is the generally...
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 :pre...
2008 Mar 28
10
Inheriting from AdminController intstead from ApplicationController
Hi
I would like to do the following:
I have created an admin namespace and the required folders app/admin
views/admin etc. And then I wanted all controllers under app/admin to
inherit from a controller named AdminController which resists under
app/admin/admin.rb instead of inhereting from ApplicationController,
so I could better separate between admin and public section. The
AdminController looks like this:
module Admin
class AdminController < ActionController::Base
include AuthenticatedSystem
helper :all
protect_from_forgery
layout ''admin/layouts/admin''
end
e...
2008 Sep 06
6
Configuring custom library
...class << self
attr_accessor :account_system_type
end
end"
Now I wanna configure
AccountSystem.account_system_type=AccountSystem::SINGLE in one app. I
used an initializer: config/initializers/account_initialization.rb
where I put this line in.
I included my AccountSystem in the ApplicationController.
So now I''d like to check within my controllers the value of
AccountSystem.account_system_type
But there it is empty!
However if I run "Ruby script\console" and type
AccountSystem.account_system_type I get the value of 1 as I would
expect.
How can I achieve the same result...
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 --------------
An HTML attachment was...
2009 Aug 10
2
A copy of ApplicationController has been removed from the module tree but is still active!
...in initialize.rb). I''m
thinking this might be a potential source of the problems.
I have read about a number of people encountering this problem, and
the general consensus about a workaround is to set the offending class
as "unloadable". Will setting "unloadable" in ApplicationController
propagate to the other controllers which subclass
ApplicationController?
How do we trace down the actual cause of this problem and fix it?
2008 Feb 22
7
Testing misc methods in ApplicationController
...ort of method that is added to
application_controller so that all controllers can use it. It must be
something simple that i''m doing wrong/omitting, can anyone help?
eg if i have this empty method in application_controller
def andreplace(str)
end
and my spec looks like this:
describe ApplicationController do
describe "andreplace(str)" do
it "should format ands for ferret search" do
andreplace("foo and bar").should eql("+foo +bar")
end
end
end
Currently, the test breaks, saying:
NoMethodError in ''ApplicationController andreplac...
2006 Jun 18
2
Why can''t I use a session? (Symbol as array index)
Hi All
I can''t for the life of me see what is wrong with this. Maybe it''s cause
it''s midnight...
I want to put some data in a session and I have some code like this:
class ApplicationController < ActionController::Base
model :mything
def ApplicationController.chosen_thing
session[:chosen_thing] ||= MyThing.defaultThing
end
end
So whenever I try to access ApplicationController.mything in one of the
controller subclasses I get the error below.
Any help much appreciat...
2006 Feb 01
2
Uninitialized constant ApplicationController?
...rying to start my Rails server after doing a long complex switch
from Postgres to MySQL, and I''m getting the following error:
=> Booting WEBrick...
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
`const_missing'': uninitialized constant ApplicationController
(NameError)
from script/../config/../vendor/plugins/user_engine/lib/user_engine.rb:74:in
`included''
from ./script/../config/../app/helpers/application_helper.rb:5
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
from /u...
2007 Jun 16
2
Specs don''t find modules when using the secure_actions or ssl_requirement plugin
Hello,
I''m trying the secure_actions plugin (or ssl_requirements)
I''m installed the plugin, and added the include in application controller:
class ApplicationController < ActionController::Base
include ExceptionNotifiable
include AuthenticatedSystem
include SecureActions
...
but when I try to run the specs I got this error:
/home/edgar/sandboxes/sugarstats/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:...
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 confirm my registration from the email it sent. But the login_required
method -- which is in my member_system.rb ("member" is...
2006 Jun 01
9
access model from controller
Hello,
Rather new to RoR, so I''m not sure about the terminology and such :-/ .
My question is: how could I know the model which is associated to a
controller?
For example:
- controller class is TestController, which is a subclass of
ApplicationController
- associated model class is Test
How could I write some code in a method of ApplicationController to
dermine the current associated model?
So, if I have a "foo" method in ApplicationController (and no such
method in TestController), when I try to go to /test/foo,
ApplicationCont...
2007 Oct 21
8
Interesting shared behaviour side-effect
Given the following ApplicationController specs:
describe ApplicationController, "one facet", :shared => true do
it ''foo'' ...
it ''bar'' ...
end
describe ApplicationController, "some other facet", :shared =>
true do
it ''abc'' ......
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 I''ve
uploaded it in app/views/application/siginin_form.rhtml...
2007 Jan 06
0
ApplicationController common view
I created a user login system in ApplicationController. There is a def
called signin. It needs a view file, signin.rhtml
I have a couple of other controllers inheriting from
ApplicationController. Where can I place the view file so it is
viewable across all controllers? I tried the root view folder but that
didn''t work.
Right now, I would...