Displaying 20 results from an estimated 3000 matches similar to: "ActionController <-> ActiveView code access ambiguity"
2006 Mar 09
4
Stop users accessing methods.
Hello all.
Is there a way to stop users from being able to access a controllers
methods without affecting the ability of other controllers to use them?
i.e
FooController
def secret
#Stuff
end
end
BarController
def index
redirect_to :controller => ''foo'', action => ''secret'', :id => ''007''
end
end
But directly
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 <
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)
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 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/.
2006 Apr 29
1
reloading include-modules inside controller not working
Hi guys,
I would expect an ActionController-derived class to reload _completely_ in
development mode.
class FooController < ApplicationController
include FancyStuffSupport
def index
# bla
end
# more actions here
end
However, the ''FancyStuffSupport'' is not reloaded, only the ''FooController''
itself. Can this behaviour be changed? I feel back
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 Apr 07
0
How to combine rjs with ActiveView::Helper?
Suppose in controller:
class ArticlesController < ApplicationController
def search
...
render :update do|page|
page.replace_html ''panel_tab_searchresults'',:partial => ''article'',
:object =>@articles
end
end
And i want to add ajax styled Paginator to the view,i have got the
method and i can work well directly used in view:
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
2009 Oct 18
4
NoMethodError in User sessionsController#new
I''m setting up authentication with Authlogic and I get this error.
I''ve done some searching but with no success. I tried setting the
current_user method in Application_controller to protected and not
private, on the recommendation in Stack Overflow.
Error in browser-----------------
NoMethodError in User sessionsController#new
undefined method `require_no_user'' for
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
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 Dec 25
18
rescue_from ActionController::RoutingError II
OK ... so I''m not supposed to use it but ...
Why doesn''t rescue_from ActionController::RoutingError work witht he
code from
http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details
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
2006 Jun 02
1
controller instance methods available in rhtml?
In rhtml, you have access to controller. I am trying to set an instance var
in my controller, then retrieve it in my form display. I know I could do
this through one of the hashes I have access to, but I''m trying to
understand why I can''t do it this way.
No matter what, when I try to output from my rhtml either
<%= controller.whynot || ''Unknown'' %> or
2007 Nov 23
12
namespaced controllers
Out of curiosity, I''ve seen the following fail:
module Admin
describe MyController
...
end
end
But this works fine:
describe Admin::MyController
..
end
Why?
Scott
2010 Jan 12
8
tips on how to write a controller test for models associated with currently logged in user
I have a controller test here:
http://gist.github.com/275616, which works fine when account is an
independent model, however I want:
an account to be a property of user, ( and created and associated when
a user is)
when the user goes to /account/edit it should on edit the account of
the logged in user -
I can make rails do this, but I''m utterly baffled how I should alter
this test to
2007 Aug 04
5
reusable specs - almost there
I have a lot of controllers with virtually identical functionality for most
actions. I''ve been using shared behaviours to DRY things up a bit, but I
still have to create separate behaviours for each context before I can use
the shared behaviours
what I have now is a generic file which contains all the behaviours and
examples common to all the controllers, and that file gets loaded from
2005 Dec 15
5
initialize called more than once?
Hi,
In my test case below, it seems that ''initialize'' is called everytime
''hello'' is called. Is this by design, a bug, or my pilot error?
class FooController < ApplicationController
def initialize
print "\n initialize \n"
end
def hello
print "\n hello \n"
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,